Create a ScopeExit that will invoke function on destruction.

Synopsis

Declared in <bdlb_scopeexit.h>

explicit
ScopeExit(void(* function)());

Description

Create a ScopeExit object, which, upon its destruction will invoke the specified function unless the release method was called. If function is copied into the EXIT_FUNC member, and that copy throws an exception, invoke function and rethrow the exception. The behavior is undefined if function or the member instance of EXIT_FUNC throws an exception upon invocation. Note that this separate constructor for function pointers exists because without it the forwarding logic in the templated constructor implementation generates warnings about meaningless types generated.

Parameters

Name

Description

function

function pointer invoked on destruction unless release is called

Created with MrDocs