Sierra Toolkit  Version of the Day
pair_rdestl.h
1 #ifndef RDESTL_PAIR_H
2 #define RDESTL_PAIR_H
3 
4 #include <stk_util/util/type_traits_rdestl.h>
5 
6 namespace rde
7 {
8 //=============================================================================
9 template<typename T1, typename T2>
10 struct pair
11 {
12  typedef T1 first_type;
13  typedef T2 second_type;
14 
15  pair() {}
16  pair(const T1& a, const T2& b): first(a), second(b) {}
17  explicit pair(const T1& a): first(a) {}
18 
19  pair(const pair<T1,T2>& rhs) : first(rhs.first), second(rhs.second) {}
20 
21  pair& operator=(const pair<T1,T2>& rhs)
22  {
23  first = rhs.first;
24  second = rhs.second;
25  return *this;
26  }
27 
28  T1 first;
29  T2 second;
30 };
31 
32 //=============================================================================
33 // Pair is POD if every element is POD/fundamental
34 template<typename T1, typename T2> struct is_pod<pair<T1, T2> >
35 {
36  enum { value = (is_pod<T1>::value || is_fundamental<T1>::value) &&
37  (is_pod<T2>::value || is_fundamental<T2>::value) };
38 };
39 
40 //-----------------------------------------------------------------------------
41 template<typename T1, typename T2>
42 pair<T1, T2> make_pair(const T1& a, const T2& b)
43 {
44  return pair<T1, T2>(a, b);
45 }
46 
47 }
48 
49 //-----------------------------------------------------------------------------
50 #endif // #ifndef RDESTL_PAIR_H