AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::error::FinallyGuard Class Reference

#include <FinallyGuard.h>

Public Member Functions

 FinallyGuard (const std::function< void()> &finallyFunction)
 
 FinallyGuard (const std::function< void()> &&finallyFunction)
 
 ~FinallyGuard ()
 

Detailed Description

Define a class that can be used to run a function when the object goes out of scope.

This simulates try-finally statements. The following structure:

try {
<try_block>
} finally {
<finally_block>
}

can be replaced by:

FinallyGuard guard { []{ <finally_block> }};
<try_block>

Constructor & Destructor Documentation

◆ FinallyGuard() [1/2]

alexaClientSDK::avsCommon::utils::error::FinallyGuard::FinallyGuard ( const std::function< void()> &  finallyFunction)
inline

Constructor.

Parameters
finallyFunctionThe function to be executed when the object goes out of scope.

◆ FinallyGuard() [2/2]

alexaClientSDK::avsCommon::utils::error::FinallyGuard::FinallyGuard ( const std::function< void()> &&  finallyFunction)
inline

Constructor.

Parameters
finallyFunctionThe function to be executed when the object goes out of scope.

◆ ~FinallyGuard()

alexaClientSDK::avsCommon::utils::error::FinallyGuard::~FinallyGuard ( )
inline

Destructor. Runs m_function during destruction.


The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0