MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tie.hpp
Go to the documentation of this file.
1 #ifndef TIE_HPP
2 #define TIE_HPP
3 
9 #include <Config.hpp>
10 
11 #include <utility>
12 
13 namespace mgx {
14 namespace util {
15 
16 // Code taken from the Boost library !
22 template <typename T, typename U> struct refpair {
23  typedef T first_type;
24  typedef U second_type;
25 
27  refpair(T& x, U& y)
28  : first(x)
29  , second(y)
30  {
31  }
33  refpair(refpair const& rp)
34  : first(rp.first)
35  , second(rp.second)
36  {
37  }
38 
40  refpair& operator=(std::pair<T, U> const& p)
41  {
42  first = p.first;
43  second = p.second;
44  return *this;
45  }
46 
48  T& first;
50  U& second;
51 };
52 
66 template <typename T, typename U> inline refpair<T, U> tie(T& x, U& y) {
67  return refpair<T, U>(x, y);
68 }
69 } // namespace util
70 } // namespace mgx
71 #endif
U & second
The second member of the pair.
Definition: Tie.hpp:50
refpair & operator=(std::pair< T, U > const &p)
Assign the values of p to the references in this pair.
Definition: Tie.hpp:40
T & first
The first member of the pair.
Definition: Tie.hpp:48
refpair(refpair const &rp)
Construct a copy.
Definition: Tie.hpp:33
Class used to hold references for the util::tie() function.
Definition: Tie.hpp:22
refpair(T &x, U &y)
Construct a pair of references to x and y.
Definition: Tie.hpp:27