Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_pair.h
Go to the documentation of this file.
1// -*- C++ -*-
2
43#ifndef _RWSTD_RW_PAIR_H_INCLUDED
44#define _RWSTD_RW_PAIR_H_INCLUDED
45
46#ifndef _RWSTD_RW_FUNCBASE_H_INCLUDED
47# include <rw/_funcbase.h> // for less
48#endif // _RWSTD_RW_FUNCBASE_H_INCLUDED
49
50
52
53
54// 20.2.2
55template <class _TypeT, class _TypeU>
56struct pair
57{
58 typedef _TypeT first_type;
59 typedef _TypeU second_type;
60
61 first_type first;
62 second_type second;
63
64 // 20.2.2, p2
65 pair ()
66#ifndef _RWSTD_NO_EMPTY_MEM_INITIALIZER
67 : first (/* lwg issue 265 */), second () { }
68#else
69 // assumes types satisfy the CopyConstructible requirements
70 : first (first_type ()), second (second_type ()) { }
71#endif // _RWSTD_NO_EMPTY_MEM_INITIALIZER
72
73 // 20.2.2, p3
74 pair (const first_type &__x, const second_type &__y)
75 : first (__x), second (__y) { }
76
77 // 20.2.2, p4
78 template <class _TypeX, class _TypeY>
79 pair (const pair <_TypeX, _TypeY> &__rhs)
80 : first (__rhs.first), second (__rhs.second) { }
81
82 // lwg issue 353
83 template <class _TypeX, class _TypeY>
84 pair<_TypeT, _TypeU>& operator= (const pair <_TypeX, _TypeY> &__rhs) {
85 return first = __rhs.first, second = __rhs.second, *this;
86 }
87
88};
89
90
91// 20.2.2, p5
92template <class _TypeT, class _TypeU>
93inline bool
94operator== (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
95{
96 return __x.first == __y.first && __x.second == __y.second;
97}
98
99
100template <class _TypeT, class _TypeU>
101inline bool
102operator!= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
103{
104 return !(__x == __y);
105}
106
107
108// 20.2.2, p6
109template <class _TypeT, class _TypeU>
110inline bool
111operator< (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
112{
113 _STD::less<_TypeT> __lessT;
114
115 // follows resolution of lwg issue 348
116 return __lessT (__x.first, __y.first)
117 || ( !__lessT (__y.first, __x.first)
118 && _STD::less<_TypeU>()(__x.second, __y.second));
119}
120
121
122template <class _TypeT, class _TypeU>
123inline bool
124operator> (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
125{
126 return __y < __x;
127}
128
129
130template <class _TypeT, class _TypeU>
131inline bool
132operator>= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
133{
134 return !(__x < __y);
135}
136
137
138template <class _TypeT, class _TypeU>
139inline bool
140operator<= (const pair<_TypeT, _TypeU>& __x, const pair<_TypeT, _TypeU>& __y)
141{
142 return !(__y < __x);
143}
144
145
146// 20.2.2, p7, signature follows lwg issue 181
147template <class _TypeT, class _TypeU>
148inline pair<_TypeT, _TypeU>
149make_pair (_TypeT __x, _TypeU __y)
150{
151 return pair<_TypeT, _TypeU>(__x, __y);
152}
153
154
155} // namespace std
156
157
158#endif // _RWSTD_RW_PAIR_H_INCLUDED
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
bool operator>(const DistancePair &lhs, const DistancePair &rhs)
Definition graph.cpp:47
bool operator==(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14737
bool operator!=(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14762
bool operator<(const json_pointer< RefStringTypeLhs > &lhs, const json_pointer< RefStringTypeRhs > &rhs) noexcept
Definition json.h:14787
Definition json.h:5363