tie.h

Go to the documentation of this file.
00001 #ifndef VVLIB_UTIL_TIE_H
00002 #define VVLIB_UTIL_TIE_H
00003 
00009 #include <config.h>
00010 #include <utility>
00014 namespace util
00015 {
00016 
00017   // Code taken from the Boost library !
00023   template< typename T, typename U >
00024     struct refpair
00025     {
00026       typedef T first_type;
00027       typedef U second_type;
00028 
00030       refpair( T& x, U& y ) : first(x), second(y) {}
00032       refpair(refpair const& rp) : first(rp.first), second(rp.second) {}
00033 #ifdef USE_CXX0X
00034       refpair(refpair&&) = default;
00035 #endif
00036 
00037       refpair& operator=( std::pair<first_type, second_type> const& p )
00038       {
00039         first = p.first;
00040         second = p.second;
00041         return *this;
00042       }
00043 
00044 #ifdef USE_CXX0X
00045       refpair& operator=( std::pair<first_type, second_type> && p)
00046       {
00047         first = std::move(p.first);
00048         second = std::move(p.second);
00049         return *this;
00050       }
00051 #endif
00052 
00054       T& first;
00056       U& second;
00057     };
00058 
00072   template< typename T, typename U >
00073     inline refpair<T, U> tie( T& x, U& y ) { return refpair<T, U>(x, y); }
00074 
00075 };
00076 
00077 #endif // VVLIB_UTIL_TIE_H
00078 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Fri May 31 15:37:53 2013 for VVE by  doxygen 1.6.3