RefToValue.h

00001 
00002 // The Loki Library
00003 // Copyright (c) 2006 Richard Sposato
00004 // Copyright (c) 2006 Peter Kümmel
00005 // Permission to use, copy, modify, distribute and sell this software for any 
00006 //     purpose is hereby granted without fee, provided that the above copyright 
00007 //     notice appear in all copies and that both that copyright notice and this 
00008 //     permission notice appear in supporting documentation.
00009 // The authors make no representations about the 
00010 //     suitability of this software for any purpose. It is provided "as is" 
00011 //     without express or implied warranty.
00013 #ifndef LOKI_REFTOVALUE_INC_
00014 #define LOKI_REFTOVALUE_INC_
00015 
00016 // $Id: RefToValue.h 751 2006-10-17 19:50:37Z syntheticpp $
00017 
00018 
00019 namespace Loki
00020 {
00021 
00029 
00030     template <class T>
00031     class RefToValue
00032     {   
00033     public:
00034     
00035         RefToValue(T& ref) : ref_(ref) 
00036         {}
00037 
00038         RefToValue(const RefToValue& rhs) : ref_(rhs.ref_)
00039         {}
00040 
00041         operator T& () const 
00042         {
00043             return ref_;
00044         }
00045 
00046     private:
00047         // Disable - not implemented
00048         RefToValue();
00049         RefToValue& operator=(const RefToValue&);
00050         
00051         T& ref_;
00052     };
00053 
00054 
00059 
00060     template <class T>
00061     inline RefToValue<T> ByRef(T& t)
00062     {
00063         return RefToValue<T>(t);
00064     }    
00065     
00066 }
00067 
00068 
00069 #endif // end file guardian
00070 

Generated on Sun Feb 25 16:52:26 2007 for Loki by  doxygen 1.5.1-p1