mn_pair.hpp
Go to the documentation of this file.
1 
18 #ifndef _MINILIB_19ee7665_8c63_48b7_803f_9c056afce956_H_
19 #define _MINILIB_19ee7665_8c63_48b7_803f_9c056afce956_H_
20 
21 #include "../mn_typetraits.hpp"
22 #include "../mn_algorithm.hpp"
23 
24 namespace mn {
25 
26  namespace container {
27  template <typename TFIRST, typename TSECOND>
28  struct basic_pair {
29  using first_type = TFIRST;
30  using pointer_first = TFIRST*;
31  using reference_first = TFIRST&;
32  using const_reference_first = const TFIRST&;
33 
34  using second_type = TSECOND;
35  using pointer_second = TSECOND*;
36  using reference_second = TSECOND&;
37  using const_reference_second = const TSECOND&;
38 
40 
41  basic_pair() { }
42 
43  explicit basic_pair(const reference_first a) noexcept
44  : first(a) { }
46  : first(a), second(b) { }
47 
48  basic_pair(const self_type& other) noexcept
49  : first(other.first), second(other.second) { }
50 
51  void swap(const self_type& other) noexcept {
52  self_type _temp(this);
53  other = this;
54  this = _temp;
55  }
56  self_type& operator = (const self_type& rhs) noexcept {
57  first = rhs.first;
58  second = rhs.second;
59  return *this;
60  }
61 
62  bool operator == (const self_type& rhs) noexcept {
63  if(first != rhs.first) return false;
64  return second == rhs.second;
65  }
66  bool operator != (const self_type& rhs) noexcept {
67  if(first == rhs.first) return false;
68  return second != rhs.second;
69  }
70 
71 
74  };
75 
76  template<typename TFIRST, typename TSECOND>
77  basic_pair<TFIRST, TSECOND> make_pair(const TFIRST& a, const TSECOND& b) {
78  return basic_pair<TFIRST, TSECOND>(a, b);
79  }
80 
81  template <typename ForwardIterator, typename TComp>
82  inline constexpr basic_pair<ForwardIterator,ForwardIterator> equal_range (ForwardIterator first,
83  ForwardIterator last,
84  const TComp& value) {
86 
87  rv.second = rv.first = mn::lower_bound (first, last, value);
88  while (rv.second != last && !(value < *(rv.second)))
89  ++ rv.second;
90  return rv;
91  }
92 
93  template<typename TFIRST, typename TSECOND>
95  }
96 
97  template <typename TFIRST, typename TSECOND>
98  struct is_pod< container::pair<TFIRST, TSECOND> > {
99  enum {
102  };
103  };
104 
105 }
106 
107 #endif
basic_pair< TFIRST, TSECOND > make_pair(const TFIRST &a, const TSECOND &b)
Definition: mn_pair.hpp:77
basic_pair< TFIRST, TSECOND > pair
Definition: mn_pair.hpp:94
constexpr basic_pair< ForwardIterator, ForwardIterator > equal_range(ForwardIterator first, ForwardIterator last, const TComp &value)
Definition: mn_pair.hpp:82
Definition: mn_allocator_typetraits.hpp:25
constexpr TIter lower_bound(TIter first, TIter last, const TPred &value)
Definition: mn_algorithm.hpp:160
Definition: mn_pair.hpp:28
second_type second
Definition: mn_pair.hpp:73
TSECOND & reference_second
Definition: mn_pair.hpp:36
TFIRST & reference_first
Definition: mn_pair.hpp:31
TFIRST * pointer_first
Definition: mn_pair.hpp:30
basic_pair(const reference_first a, reference_second b)
Definition: mn_pair.hpp:45
basic_pair()
Definition: mn_pair.hpp:41
bool operator==(const self_type &rhs) noexcept
Definition: mn_pair.hpp:62
first_type first
Definition: mn_pair.hpp:72
void swap(const self_type &other) noexcept
Definition: mn_pair.hpp:51
TSECOND * pointer_second
Definition: mn_pair.hpp:35
self_type & operator=(const self_type &rhs) noexcept
Definition: mn_pair.hpp:56
TFIRST first_type
Definition: mn_pair.hpp:29
TSECOND second_type
Definition: mn_pair.hpp:34
basic_pair(const reference_first a) noexcept
Definition: mn_pair.hpp:43
const TFIRST & const_reference_first
Definition: mn_pair.hpp:32
bool operator!=(const self_type &rhs) noexcept
Definition: mn_pair.hpp:66
basic_pair(const self_type &other) noexcept
Definition: mn_pair.hpp:48
const TSECOND & const_reference_second
Definition: mn_pair.hpp:37
@ value
Definition: mn_typetraits.hpp:126
Definition: mn_typetraits.hpp:357
Definition: mn_typetraits.hpp:249