This file is indexed.

/usr/include/loki/ScopeGuard.h is in libloki-dev 0.1.7-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2000 Andrei Alexandrescu
// Copyright (c) 2000 Petru Marginean
// Copyright (c) 2005 Joshua Lehrer
//
// Permission to use, copy, modify, distribute and sell this software for any 
//     purpose is hereby granted without fee, provided that the above copyright 
//     notice appear in all copies and that both that copyright notice and this 
//     permission notice appear in supporting documentation.
// The author makes no representations about the 
//     suitability of this software for any purpose. It is provided "as is" 
//     without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SCOPEGUARD_INC_
#define LOKI_SCOPEGUARD_INC_

// $Id: ScopeGuard.h 799 2006-12-20 00:37:13Z rich_sposato $


#include <loki/RefToValue.h>

/// \defgroup ExceptionGroup Exception-safe code

namespace Loki
{

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImplBase
    /// \ingroup ExceptionGroup
    ///
    /// Base class used by all ScopeGuard implementations.  All commonly used
    /// functions are in this class (e.g. - Dismiss and SafeExecute).
    ///
    /// See Andrei's and Petru Marginean's CUJ article
    /// http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm
    ///
    /// Changes to the original code by Joshua Lehrer:
    /// http://www.lehrerfamily.com/scopeguard.html
    ////////////////////////////////////////////////////////////////

    class ScopeGuardImplBase
    {
        /// Copy-assignment operator is not implemented and private.
        ScopeGuardImplBase& operator =(const ScopeGuardImplBase&);

    protected:

        ~ScopeGuardImplBase()
        {}

        /// Copy-constructor takes over responsibility from other ScopeGuard.
        ScopeGuardImplBase(const ScopeGuardImplBase& other) throw() 
            : dismissed_(other.dismissed_)
        {
            other.Dismiss();
        }

        template <typename J>
        static void SafeExecute(J& j) throw() 
        {
            if (!j.dismissed_)
                try
                {
                    j.Execute();
                }
                catch(...)
                {}
        }
        
        mutable bool dismissed_;

    public:
        ScopeGuardImplBase() throw() : dismissed_(false) 
        {}

        void Dismiss() const throw() 
        {
            dismissed_ = true;
        }
    };

    ////////////////////////////////////////////////////////////////
    ///
    /// \typedef typedef const ScopeGuardImplBase& ScopeGuard
    /// \ingroup ExceptionGroup
    ///
    ////////////////////////////////////////////////////////////////

    typedef const ScopeGuardImplBase& ScopeGuard;

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl0
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with no parameters.  ScopeGuard ignores any value returned from the
    /// call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template <typename F>
    class ScopeGuardImpl0 : public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl0<F> MakeGuard(F fun)
        {
            return ScopeGuardImpl0<F>(fun);
        }

        ~ScopeGuardImpl0() throw() 
        {
            SafeExecute(*this);
        }

        void Execute() 
        {
            fun_();
        }

    protected:
        ScopeGuardImpl0(F fun) : fun_(fun) 
        {}

        F fun_;
    };

    template <typename F> 
    inline ScopeGuardImpl0<F> MakeGuard(F fun)
    {
        return ScopeGuardImpl0<F>::MakeGuard(fun);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl1
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with one parameter.  Each parameter is copied by value - use
    /// ::Loki::ByRef if you must use a reference instead.  ScopeGuard ignores
    /// any value returned from the call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template <typename F, typename P1>
    class ScopeGuardImpl1 : public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
        {
            return ScopeGuardImpl1<F, P1>(fun, p1);
        }

        ~ScopeGuardImpl1() throw() 
        {
            SafeExecute(*this);
        }

        void Execute()
        {
            fun_(p1_);
        }

    protected:
        ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1) 
        {}

        F fun_;
        const P1 p1_;
    };

    template <typename F, typename P1> 
    inline ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
    {
        return ScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl2
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with two parameters.  Each parameter is copied by value - use
    /// ::Loki::ByRef if you must use a reference instead.  ScopeGuard ignores
    /// any value returned from the call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template <typename F, typename P1, typename P2>
    class ScopeGuardImpl2: public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
        {
            return ScopeGuardImpl2<F, P1, P2>(fun, p1, p2);
        }

        ~ScopeGuardImpl2() throw() 
        {
            SafeExecute(*this);
        }

        void Execute()
        {
            fun_(p1_, p2_);
        }

    protected:
        ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2) 
        {}

        F fun_;
        const P1 p1_;
        const P2 p2_;
    };

    template <typename F, typename P1, typename P2>
    inline ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
    {
        return ScopeGuardImpl2<F, P1, P2>::MakeGuard(fun, p1, p2);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl3
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with three parameters.  Each parameter is copied by value - use
    /// ::Loki::ByRef if you must use a reference instead.  ScopeGuard ignores
    /// any value returned from the call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template <typename F, typename P1, typename P2, typename P3>
    class ScopeGuardImpl3 : public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
        {
            return ScopeGuardImpl3<F, P1, P2, P3>(fun, p1, p2, p3);
        }

        ~ScopeGuardImpl3() throw() 
        {
            SafeExecute(*this);
        }

        void Execute()
        {
            fun_(p1_, p2_, p3_);
        }

    protected:
        ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3) 
        {}

        F fun_;
        const P1 p1_;
        const P2 p2_;
        const P3 p3_;
    };

    template <typename F, typename P1, typename P2, typename P3>
    inline ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
    {
        return ScopeGuardImpl3<F, P1, P2, P3>::MakeGuard(fun, p1, p2, p3);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl4
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with four parameters.  Each parameter is copied by value - use
    /// ::Loki::ByRef if you must use a reference instead.  ScopeGuard ignores
    /// any value returned from the call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template < typename F, typename P1, typename P2, typename P3, typename P4 >
    class ScopeGuardImpl4 : public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard(
            F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
        {
            return ScopeGuardImpl4< F, P1, P2, P3, P4 >( fun, p1, p2, p3, p4 );
        }

        ~ScopeGuardImpl4() throw() 
        {
            SafeExecute( *this );
        }

        void Execute()
        {
            fun_( p1_, p2_, p3_, p4_ );
        }

    protected:
        ScopeGuardImpl4( F fun, P1 p1, P2 p2, P3 p3, P4 p4 ) :
             fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 )
        {}

        F fun_;
        const P1 p1_;
        const P2 p2_;
        const P3 p3_;
        const P4 p4_;
    };

    template < typename F, typename P1, typename P2, typename P3, typename P4 >
    inline ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
    {
        return ScopeGuardImpl4< F, P1, P2, P3, P4 >::MakeGuard( fun, p1, p2, p3, p4 );
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ScopeGuardImpl5
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a standalone function or class static function
    /// with five parameters.  Each parameter is copied by value - use
    /// ::Loki::ByRef if you must use a reference instead.  ScopeGuard ignores
    /// any value returned from the call within the Execute function.
    ///
    /// This class has a single standalone helper function, MakeGuard which
    /// creates and returns a ScopeGuard.
    ///
    ////////////////////////////////////////////////////////////////

    template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
    class ScopeGuardImpl5 : public ScopeGuardImplBase
    {
    public:
        static ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard(
            F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
        {
            return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >( fun, p1, p2, p3, p4, p5 );
        }

        ~ScopeGuardImpl5() throw() 
        {
            SafeExecute( *this );
        }

        void Execute()
        {
            fun_( p1_, p2_, p3_, p4_, p5_ );
        }

    protected:
        ScopeGuardImpl5( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) :
             fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 ), p5_( p5 )
        {}

        F fun_;
        const P1 p1_;
        const P2 p2_;
        const P3 p3_;
        const P4 p4_;
        const P5 p5_;
    };

    template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
    inline ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
    {
        return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >::MakeGuard( fun, p1, p2, p3, p4, p5 );
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ObjScopeGuardImpl0
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a class per-instance member function with no
    /// parameters.  ScopeGuard ignores any value returned from the call within
    /// the Execute function.
    ///
    /// This class has 3 standalone helper functions which create a ScopeGuard.
    /// One is MakeObjGuard, which is deprecated but provided for older code.
    /// The other two are MakeGuard overloads, one which takes a pointer to an
    /// object, and the other which takes a reference.
    ///
    ////////////////////////////////////////////////////////////////

    template <class Obj, typename MemFun>
    class ObjScopeGuardImpl0 : public ScopeGuardImplBase
    {
    public:
        static ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
        {
            return ObjScopeGuardImpl0<Obj, MemFun>(obj, memFun);
        }

        ~ObjScopeGuardImpl0() throw() 
        {
            SafeExecute(*this);
        }

        void Execute() 
        {
            (obj_.*memFun_)();
        }

    protected:
        ObjScopeGuardImpl0(Obj& obj, MemFun memFun) : obj_(obj), memFun_(memFun) 
        {}

        Obj& obj_;
        MemFun memFun_;
    };

    template <class Obj, typename MemFun>
    inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
    {
        return ObjScopeGuardImpl0<Obj, MemFun>::MakeObjGuard(obj, memFun);
    }

    template <typename Ret, class Obj1, class Obj2>
    inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 &obj) 
    {
      return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun);
    }

    template <typename Ret, class Obj1, class Obj2>
    inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 *obj) 
    {
      return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ObjScopeGuardImpl1
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a class per-instance member function with one
    /// parameter.  The parameter is copied by value - use ::Loki::ByRef if you
    /// must use a reference instead.  ScopeGuard ignores any value returned
    /// from the call within the Execute function.
    ///
    /// This class has 3 standalone helper functions which create a ScopeGuard.
    /// One is MakeObjGuard, which is deprecated but provided for older code.
    /// The other two are MakeGuard overloads, one which takes a pointer to an
    /// object, and the other which takes a reference.
    ///
    ////////////////////////////////////////////////////////////////

    template <class Obj, typename MemFun, typename P1>
    class ObjScopeGuardImpl1 : public ScopeGuardImplBase
    {
    public:
        static ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
        {
            return ObjScopeGuardImpl1<Obj, MemFun, P1>(obj, memFun, p1);
        }

        ~ObjScopeGuardImpl1() throw() 
        {
            SafeExecute(*this);
        }

        void Execute() 
        {
            (obj_.*memFun_)(p1_);
        }

    protected:
        ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1) 
        {}
        
        Obj& obj_;
        MemFun memFun_;
        const P1 p1_;
    };

    template <class Obj, typename MemFun, typename P1>
    inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
    {
        return ObjScopeGuardImpl1<Obj, MemFun, P1>::MakeObjGuard(obj, memFun, p1);
    }

    template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
    inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 &obj, P1b p1) 
    {
      return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1);
    }

    template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
    inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 *obj, P1b p1) 
    {
      return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ObjScopeGuardImpl2
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a class per-instance member function with two
    /// parameters.  Each parameter is copied by value - use ::Loki::ByRef if you
    /// must use a reference instead.  ScopeGuard ignores any value returned
    /// from the call within the Execute function.
    ///
    /// This class has 3 standalone helper functions which create a ScopeGuard.
    /// One is MakeObjGuard, which is deprecated but provided for older code.
    /// The other two are MakeGuard overloads, one which takes a pointer to an
    /// object, and the other which takes a reference.
    ///
    ////////////////////////////////////////////////////////////////

    template <class Obj, typename MemFun, typename P1, typename P2>
    class ObjScopeGuardImpl2 : public ScopeGuardImplBase
    {
    public:
        static ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
        {
            return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>(obj, memFun, p1, p2);
        }

        ~ObjScopeGuardImpl2() throw() 
        {
            SafeExecute(*this);
        }

        void Execute() 
        {
            (obj_.*memFun_)(p1_, p2_);
        }

    protected:
        ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2) 
        {}

        Obj& obj_;
        MemFun memFun_;
        const P1 p1_;
        const P2 p2_;
    };

    template <class Obj, typename MemFun, typename P1, typename P2>
    inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
    {
        return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>::MakeObjGuard(obj, memFun, p1, p2);
    }

    template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
    inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 &obj, P1b p1, P2b p2) 
    {
      return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2);
    }

    template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
    inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 *obj, P1b p1, P2b p2) 
    {
      return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2);
    }

    ////////////////////////////////////////////////////////////////
    ///
    /// \class ObjScopeGuardImpl3
    /// \ingroup ExceptionGroup
    ///
    /// Implementation class for a class per-instance member function with three
    /// parameters.  Each parameter is copied by value - use ::Loki::ByRef if you
    /// must use a reference instead.  ScopeGuard ignores any value returned
    /// from the call within the Execute function.
    ///
    /// This class has 3 standalone helper functions which create a ScopeGuard.
    /// One is MakeObjGuard, which is deprecated but provided for older code.
    /// The other two are MakeGuard overloads, one which takes a pointer to an
    /// object, and the other which takes a reference.
    ///
    ////////////////////////////////////////////////////////////////

    template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
    class ObjScopeGuardImpl3 : public ScopeGuardImplBase
    {
    public:
        static ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
            Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
        {
            return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >( obj, memFun, p1, p2, p3 );
        }

        ~ObjScopeGuardImpl3() throw() 
        {
            SafeExecute( *this );
        }

        void Execute() 
        {
            ( obj_.*memFun_ )( p1_, p2_, p3_ );
        }

    protected:
        ObjScopeGuardImpl3( Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 ) :
             obj_( obj ), memFun_( memFun ), p1_( p1 ), p2_( p2 ), p3_( p3 )
        {}

        Obj& obj_;
        MemFun memFun_;
        const P1 p1_;
        const P2 p2_;
        const P3 p3_;
    };

    template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
    inline ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
        Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
    {
        return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >::MakeObjGuard(
            obj, memFun, p1, p2, p3 );
    }

    template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
        typename P2a, typename P2b, typename P3a, typename P3b >
    inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
        MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 & obj, P1b p1, P2b p2, P3b p3 )
    {
      return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
          ::MakeObjGuard( obj, memFun, p1, p2, p3 );
    }

    template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
        typename P2a, typename P2b, typename P3a, typename P3b >
    inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
        MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 * obj, P1b p1, P2b p2, P3b p3 )
    {
      return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
          ::MakeObjGuard( *obj, memFun, p1, p2, p3 );
    }

} // namespace Loki

#define LOKI_CONCATENATE_DIRECT(s1, s2)  s1##s2
#define LOKI_CONCATENATE(s1, s2)         LOKI_CONCATENATE_DIRECT(s1, s2)
#define LOKI_ANONYMOUS_VARIABLE(str)     LOKI_CONCATENATE(str, __LINE__)

#define LOKI_ON_BLOCK_EXIT      ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeGuard
#define LOKI_ON_BLOCK_EXIT_OBJ  ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeObjGuard

#endif // end file guardian