15#ifndef LOKI_SCOPEGUARD_H_
16#define LOKI_SCOPEGUARD_H_
18#include "mongo/platform/compiler.h"
104 : dismissed_(other.dismissed_)
109 template <
typename J>
110 static void SafeExecute(J& j)
throw()
121 mutable bool dismissed_;
127 void Dismiss()
const throw()
146 template <
typename F>
172 template <
typename F>
178 template <
typename F,
typename P1>
205 template <
typename F,
typename P1>
211 template <
typename F,
typename P1,
typename P2>
239 template <
typename F,
typename P1,
typename P2>
245 template <
typename F,
typename P1,
typename P2,
typename P3>
265 ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3)
274 template <
typename F,
typename P1,
typename P2,
typename P3>
282 template <
class Obj,
typename MemFun>
309 template <
class Obj,
typename MemFun>
315 template <
typename Ret,
class Obj1,
class Obj2>
316 inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 &obj)
318 return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun);
321 template <
typename Ret,
class Obj1,
class Obj2>
322 inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 *obj)
324 return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun);
327 template <
class Obj,
typename MemFun,
typename P1>
343 (obj_.*memFun_)(p1_);
347 ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1)
355 template <
class Obj,
typename MemFun,
typename P1>
361 template <
typename Ret,
class Obj1,
class Obj2,
typename P1a,
typename P1b>
362 inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 &obj, P1b p1)
364 return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1);
367 template <
typename Ret,
class Obj1,
class Obj2,
typename P1a,
typename P1b>
368 inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 *obj, P1b p1)
370 return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1);
373 template <
class Obj,
typename MemFun,
typename P1,
typename P2>
389 (obj_.*memFun_)(p1_, p2_);
393 ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2)
402 template <
class Obj,
typename MemFun,
typename P1,
typename P2>
408 template <
typename Ret,
class Obj1,
class Obj2,
typename P1a,
typename P1b,
typename P2a,
typename P2b>
409 inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 &obj, P1b p1, P2b p2)
411 return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2);
414 template <
typename Ret,
class Obj1,
class Obj2,
typename P1a,
typename P1b,
typename P2a,
typename P2b>
415 inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 *obj, P1b p1, P2b p2)
417 return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2);
422#define LOKI_CONCATENATE_DIRECT(s1, s2) s1##s2
423#define LOKI_CONCATENATE(s1, s2) LOKI_CONCATENATE_DIRECT(s1, s2)
424#define LOKI_ANONYMOUS_VARIABLE(str) LOKI_CONCATENATE(str, __LINE__)
426#define ON_BLOCK_EXIT \
427 MONGO_COMPILER_VARIABLE_UNUSED ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeGuard
428#define ON_BLOCK_EXIT_OBJ \
429 MONGO_COMPILER_VARIABLE_UNUSED ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = MakeObjGuard
Definition scopeguard.h:284
Definition scopeguard.h:329
Definition scopeguard.h:375
Transports a reference as a value Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuar...
Definition scopeguard.h:32
Definition scopeguard.h:148
Definition scopeguard.h:180
Definition scopeguard.h:213
Definition scopeguard.h:247
ScopeGuard.
Definition scopeguard.h:95
the main MongoDB namespace
Definition bulk_operation_builder.h:24
RefToValue< T > ByRef(T &t)
RefToValue creator.
Definition scopeguard.h:60
const ScopeGuardImplBase & ScopeGuard
See Andrei's and Petru Marginean's CUJ article http://www.cuj.com/documents/s=8000/cujcexp1812alexand...
Definition scopeguard.h:144