SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Topics

 rwtMakeScopeGuard Functions
 

Classes

class  RWScopeGuard0GImp< Fun >
 Derived RWScopeGuardImp for global or static member functions that take 0 parameters. More...
 
class  RWScopeGuard0MImp< Obj, Fun >
 Derived RWScopeGuardImp for member functions that take 0 parameters. More...
 
class  RWScopeGuard1GImp< Fun, P1 >
 Derived RWScopeGuardImp for global or static member functions that take 1 parameter. More...
 
class  RWScopeGuard1MImp< Obj, Fun, P1 >
 Derived RWScopeGuardImp for member functions that take 1 parameter. More...
 
class  RWScopeGuard2GImp< Fun, P1, P2 >
 Derived RWScopeGuardImp for global or static member functions that take 2 parameters. More...
 
class  RWScopeGuard2MImp< Obj, Fun, P1, P2 >
 Derived RWScopeGuardImp for member functions that take 2 parameters. More...
 
class  RWScopeGuard3GImp< Fun, P1, P2, P3 >
 Derived RWScopeGuardImp for global or static member functions that take 3 parameters. More...
 
class  RWScopeGuard3MImp< Obj, Fun, P1, P2, P3 >
 Derived RWScopeGuardImp for member functions that take 3 parameters. More...
 
class  RWScopeGuard4GImp< Fun, P1, P2, P3, P4 >
 Derived RWScopeGuardImp for global or static member functions that take 4 parameters. More...
 
class  RWScopeGuard4MImp< Obj, Fun, P1, P2, P3, P4 >
 Derived RWScopeGuardImp for member functions that take 4 parameters. More...
 
class  RWScopeGuard5GImp< Fun, P1, P2, P3, P4, P5 >
 Derived RWScopeGuardImp for global or static member functions that take 5 parameters. More...
 
class  RWScopeGuard5MImp< Obj, Fun, P1, P2, P3, P4, P5 >
 Derived RWScopeGuardImp for member functions that take 5 parameters. More...
 
class  RWScopeGuardImp
 Base class for derived RWScopeGuardImp classes. More...
 

Typedefs

typedef const RWScopeGuardImpRWScopeGuard
 

Functions

template<class T >
RWTReferenceWrapper< T > rwtMakeRef (T &t)
 

Detailed Description

Classes and functions in this group provide an implementation of the Resource Acquisition Is Initialization (RAII) programming idiom. This idiom is useful for writing exception-safe code. It relies on guarantees provided by the C++ language to perform an action when control flow leaves the current scope.

Typedef Documentation

◆ RWScopeGuard

typedef const RWScopeGuardImp& RWScopeGuard

RWScopeGuard encapsulates a function to invoke and a set of parameters to pass to that function on exit from the current local scope. It can handle functions that take up to five parameters, and those parameters can be of any type.

Example
FILE* f = fopen("file.txt", "w+");
// close the file automatically on exit from scope
// some operation that might throw
potentially_dangerous_call();
Base class for derived RWScopeGuardImp classes.
Definition scopeguard.h:32
RWScopeGuard0GImp< Func > rwtMakeScopeGuardG(Func func)
Definition scopeguard.h:576

If the action to be performed by the scope guard is no longer necessary, it may be canceled.

// prevent the action from being performed
sg.dismiss();
void dismiss() const
Definition scopeguard.h:38

Function Documentation

◆ rwtMakeRef()

template<class T >
RWTReferenceWrapper< T > rwtMakeRef ( T & t)
Deprecated
As of SourcePro 12.5, use rwRef() instead.

Creates a wrapper around an object reference.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.