1 ////////////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2006 Richard Sposato
4 // Copyright (c) 2006 Peter Kümmel
5 // Permission to use, copy, modify, distribute and sell this software for any
6 // purpose is hereby granted without fee, provided that the above copyright
7 // notice appear in all copies and that both that copyright notice and this
8 // permission notice appear in supporting documentation.
9 // The authors make no representations about the
10 // suitability of this software for any purpose. It is provided "as is"
11 // without express or implied warranty.
12 ////////////////////////////////////////////////////////////////////////////////
13 #ifndef LOKI_REFTOVALUE_INC_
14 #define LOKI_REFTOVALUE_INC_
16 // $Id: RefToValue.h 751 2006-10-17 19:50:37Z syntheticpp $
22 ////////////////////////////////////////////////////////////////////////////////
25 /// \ingroup SmartPointerGroup
26 /// Transports a reference as a value
27 /// Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard
28 ////////////////////////////////////////////////////////////////////////////////
35 RefToValue(T &ref) : ref_(ref)
38 RefToValue(const RefToValue &rhs) : ref_(rhs.ref_)
47 // Disable - not implemented
49 RefToValue &operator=(const RefToValue &);
55 ////////////////////////////////////////////////////////////////////////////////
56 /// \ingroup ExceptionGroup
57 /// RefToValue creator.
58 ////////////////////////////////////////////////////////////////////////////////
61 inline RefToValue<T> ByRef(T &t)
63 return RefToValue<T>(t);
69 #endif // end file guardian