00001 #ifndef hpp_ByRef_hpp 00002 #define hpp_ByRef_hpp 00003 00004 00005 // If we need to pass a value by reference 00006 template <class T> 00007 class ByRef 00008 { 00009 public: 00011 operator T& () const { return ref; } 00012 operator const T & () const { return ref; } 00013 00015 ByRef(T & _ref): ref(_ref) {} 00016 00017 private: 00019 ByRef & operator = (const ByRef & obj); 00021 T & ref; 00022 }; 00023 00025 template <class T> 00026 ByRef<T> byRef(T & ref) { return ByRef<T>(ref); } 00027 00028 #endif