BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslma::ExceptionGuard< OBJECT > Class Template Reference

#include <bslma_exceptionguard.h>

Public Member Functions

 ExceptionGuard (const OBJECT *object, int line, Allocator *basicAllocator=0)
 
template<class ALLOCATOR >
 ExceptionGuard (const OBJECT *object, int line, const ALLOCATOR &basicAllocator)
 
 ~ExceptionGuard ()
 
void release ()
 Release the guard from verifying the state of the object.
 
void resetValue (const OBJECT &value, int line)
 

Detailed Description

template<class OBJECT>
class bslma::ExceptionGuard< OBJECT >

This class provide a mechanism to verify the strong exception guarantee in exception-throwing code. On construction, this class stores the a copy of an object of the parameterized type OBJECT and the address of that object. On destruction, if release was not invoked, it will verify the value of the object is the same as the value of the copy create on construction. This class requires the copy constructor and operator == to be tested before use.

See bslma_exceptionguard

Constructor & Destructor Documentation

◆ ExceptionGuard() [1/2]

template<class OBJECT >
bslma::ExceptionGuard< OBJECT >::ExceptionGuard ( const OBJECT *  object,
int  line,
Allocator basicAllocator = 0 
)
inline

Create the exception guard for the specified object at the specified line number. Optionally, specify basicAllocator used to supply memory.

◆ ExceptionGuard() [2/2]

template<class OBJECT >
template<class ALLOCATOR >
bslma::ExceptionGuard< OBJECT >::ExceptionGuard ( const OBJECT *  object,
int  line,
const ALLOCATOR &  basicAllocator 
)
inline

Create the exception guard for the specified object at the specified line number. Optionally, specify basicAllocator used to supply memory.

◆ ~ExceptionGuard()

template<class OBJECT >
bslma::ExceptionGuard< OBJECT >::~ExceptionGuard ( )

Destroy the exception guard. If the guard was not released, verify that the state of the object supplied at construction has not change.

Member Function Documentation

◆ release()

template<class OBJECT >
void bslma::ExceptionGuard< OBJECT >::release ( )
inline

◆ resetValue()

template<class OBJECT >
void bslma::ExceptionGuard< OBJECT >::resetValue ( const OBJECT &  value,
int  line 
)
inline

Reset the expected state of the guarded object, if an exception should propagate past this guard, to the specified value, which is set from the specified line.


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