SourcePro® API Reference Guide

 
Classes | Modules | Typedefs | Functions

Module 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.

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...
 

Modules

 rwtMakeScopeGuard Functions
 

Typedefs

typedef const RWScopeGuardImpRWScopeGuard
 

Functions

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

Typedef Documentation

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
1 FILE* f = fopen("file.txt", "w+");
2 
3 // close the file automatically on exit from scope
4 RWScopeGuard sg = rwtMakeScopeGuardG(fclose, f);
5 
6 // some operation that might throw
7 potentially_dangerous_call();

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

1 // prevent the action from being performed
2 sg.dismiss();

Function Documentation

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 © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.