1*c2c66affSColin Finck /*
2*c2c66affSColin Finck *
3*c2c66affSColin Finck * Copyright (c) 1994
4*c2c66affSColin Finck * Hewlett-Packard Company
5*c2c66affSColin Finck *
6*c2c66affSColin Finck * Copyright (c) 1996,1997
7*c2c66affSColin Finck * Silicon Graphics Computer Systems, Inc.
8*c2c66affSColin Finck *
9*c2c66affSColin Finck * Copyright (c) 1997
10*c2c66affSColin Finck * Moscow Center for SPARC Technology
11*c2c66affSColin Finck *
12*c2c66affSColin Finck * Copyright (c) 1999
13*c2c66affSColin Finck * Boris Fomitchev
14*c2c66affSColin Finck *
15*c2c66affSColin Finck * This material is provided "as is", with absolutely no warranty expressed
16*c2c66affSColin Finck * or implied. Any use is at your own risk.
17*c2c66affSColin Finck *
18*c2c66affSColin Finck * Permission to use or copy this software for any purpose is hereby granted
19*c2c66affSColin Finck * without fee, provided the above notices are retained on all copies.
20*c2c66affSColin Finck * Permission to modify the code and to distribute modified code is granted,
21*c2c66affSColin Finck * provided the above notices are retained, and a notice that the code was
22*c2c66affSColin Finck * modified is included with the above copyright notice.
23*c2c66affSColin Finck *
24*c2c66affSColin Finck */
25*c2c66affSColin Finck
26*c2c66affSColin Finck
27*c2c66affSColin Finck /* NOTE: This is an internal header file, included by other STL headers.
28*c2c66affSColin Finck * You should not attempt to use it directly.
29*c2c66affSColin Finck */
30*c2c66affSColin Finck
31*c2c66affSColin Finck #ifndef _STLP_INTERNAL_PAIR_H
32*c2c66affSColin Finck #define _STLP_INTERNAL_PAIR_H
33*c2c66affSColin Finck
34*c2c66affSColin Finck #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
35*c2c66affSColin Finck # ifndef _STLP_TYPE_TRAITS_H
36*c2c66affSColin Finck # include <stl/type_traits.h>
37*c2c66affSColin Finck # endif
38*c2c66affSColin Finck
39*c2c66affSColin Finck # if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC)
40*c2c66affSColin Finck # include <stl/_move_construct_fwk.h>
41*c2c66affSColin Finck # endif
42*c2c66affSColin Finck #endif
43*c2c66affSColin Finck
44*c2c66affSColin Finck _STLP_BEGIN_NAMESPACE
45*c2c66affSColin Finck
46*c2c66affSColin Finck template <class _T1, class _T2>
47*c2c66affSColin Finck struct pair {
48*c2c66affSColin Finck typedef _T1 first_type;
49*c2c66affSColin Finck typedef _T2 second_type;
50*c2c66affSColin Finck
51*c2c66affSColin Finck _T1 first;
52*c2c66affSColin Finck _T2 second;
53*c2c66affSColin Finck #if defined (_STLP_CONST_CONSTRUCTOR_BUG)
pairpair54*c2c66affSColin Finck pair() {}
55*c2c66affSColin Finck #else
pairpair56*c2c66affSColin Finck pair() : first(_T1()), second(_T2()) {}
57*c2c66affSColin Finck #endif
pairpair58*c2c66affSColin Finck pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
59*c2c66affSColin Finck
60*c2c66affSColin Finck #if defined (_STLP_MEMBER_TEMPLATES)
61*c2c66affSColin Finck template <class _U1, class _U2>
pairpair62*c2c66affSColin Finck pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
63*c2c66affSColin Finck
pairpair64*c2c66affSColin Finck pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
65*c2c66affSColin Finck #endif
66*c2c66affSColin Finck
67*c2c66affSColin Finck #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
pairpair68*c2c66affSColin Finck pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)),
69*c2c66affSColin Finck second(_STLP_PRIV _AsMoveSource(src.get().second))
70*c2c66affSColin Finck {}
71*c2c66affSColin Finck #endif
72*c2c66affSColin Finck
73*c2c66affSColin Finck __TRIVIAL_DESTRUCTOR(pair)
74*c2c66affSColin Finck };
75*c2c66affSColin Finck
76*c2c66affSColin Finck template <class _T1, class _T2>
77*c2c66affSColin Finck inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
78*c2c66affSColin Finck { return __x.first == __y.first && __x.second == __y.second; }
79*c2c66affSColin Finck
80*c2c66affSColin Finck template <class _T1, class _T2>
81*c2c66affSColin Finck inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
82*c2c66affSColin Finck return __x.first < __y.first ||
83*c2c66affSColin Finck (!(__y.first < __x.first) && __x.second < __y.second);
84*c2c66affSColin Finck }
85*c2c66affSColin Finck
86*c2c66affSColin Finck #if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
87*c2c66affSColin Finck template <class _T1, class _T2>
88*c2c66affSColin Finck inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
89*c2c66affSColin Finck { return !(__x == __y); }
90*c2c66affSColin Finck
91*c2c66affSColin Finck template <class _T1, class _T2>
92*c2c66affSColin Finck inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
93*c2c66affSColin Finck { return __y < __x; }
94*c2c66affSColin Finck
95*c2c66affSColin Finck template <class _T1, class _T2>
96*c2c66affSColin Finck inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
97*c2c66affSColin Finck { return !(__y < __x); }
98*c2c66affSColin Finck
99*c2c66affSColin Finck template <class _T1, class _T2>
100*c2c66affSColin Finck inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
101*c2c66affSColin Finck { return !(__x < __y); }
102*c2c66affSColin Finck #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
103*c2c66affSColin Finck
104*c2c66affSColin Finck #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
105*c2c66affSColin Finck template <class _T1, class _T2, int _Sz>
make_pair(_T1 const & __x,_T2 const (& __y)[_Sz])106*c2c66affSColin Finck inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
107*c2c66affSColin Finck _T2 const (&__y)[_Sz])
108*c2c66affSColin Finck { return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); }
109*c2c66affSColin Finck
110*c2c66affSColin Finck template <class _T1, class _T2, int _Sz>
make_pair(_T1 const (& __x)[_Sz],_T2 const & __y)111*c2c66affSColin Finck inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
112*c2c66affSColin Finck _T2 const& __y)
113*c2c66affSColin Finck { return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); }
114*c2c66affSColin Finck
115*c2c66affSColin Finck template <class _T1, class _T2, int _Sz1, int _Sz2>
make_pair(_T1 const (& __x)[_Sz1],_T2 const (& __y)[_Sz2])116*c2c66affSColin Finck inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
117*c2c66affSColin Finck _T2 const (&__y)[_Sz2]) {
118*c2c66affSColin Finck return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
119*c2c66affSColin Finck static_cast<_T2 const*>(__y));
120*c2c66affSColin Finck }
121*c2c66affSColin Finck #endif
122*c2c66affSColin Finck
123*c2c66affSColin Finck template <class _T1, class _T2>
make_pair(_T1 __x,_T2 __y)124*c2c66affSColin Finck inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y)
125*c2c66affSColin Finck { return pair<_T1, _T2>(__x, __y); }
126*c2c66affSColin Finck
127*c2c66affSColin Finck _STLP_END_NAMESPACE
128*c2c66affSColin Finck
129*c2c66affSColin Finck #if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
130*c2c66affSColin Finck _STLP_BEGIN_RELOPS_NAMESPACE
131*c2c66affSColin Finck
132*c2c66affSColin Finck template <class _Tp>
133*c2c66affSColin Finck inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y)
134*c2c66affSColin Finck { return !(__x == __y); }
135*c2c66affSColin Finck
136*c2c66affSColin Finck template <class _Tp>
137*c2c66affSColin Finck inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y)
138*c2c66affSColin Finck { return __y < __x; }
139*c2c66affSColin Finck
140*c2c66affSColin Finck template <class _Tp>
141*c2c66affSColin Finck inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y)
142*c2c66affSColin Finck { return !(__y < __x); }
143*c2c66affSColin Finck
144*c2c66affSColin Finck template <class _Tp>
145*c2c66affSColin Finck inline bool _STLP_CALL operator>=(const _Tp& __x, const _Tp& __y)
146*c2c66affSColin Finck { return !(__x < __y); }
147*c2c66affSColin Finck
148*c2c66affSColin Finck _STLP_END_RELOPS_NAMESPACE
149*c2c66affSColin Finck #endif
150*c2c66affSColin Finck
151*c2c66affSColin Finck #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
152*c2c66affSColin Finck _STLP_BEGIN_NAMESPACE
153*c2c66affSColin Finck
154*c2c66affSColin Finck template <class _T1, class _T2>
155*c2c66affSColin Finck struct __type_traits<pair<_T1, _T2> > {
156*c2c66affSColin Finck typedef __type_traits<_T1> _T1Traits;
157*c2c66affSColin Finck typedef __type_traits<_T2> _T2Traits;
158*c2c66affSColin Finck typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor,
159*c2c66affSColin Finck typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor;
160*c2c66affSColin Finck typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor,
161*c2c66affSColin Finck typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor;
162*c2c66affSColin Finck typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator,
163*c2c66affSColin Finck typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator;
164*c2c66affSColin Finck typedef typename _Land2<typename _T1Traits::has_trivial_destructor,
165*c2c66affSColin Finck typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor;
166*c2c66affSColin Finck typedef __false_type is_POD_type;
167*c2c66affSColin Finck };
168*c2c66affSColin Finck
169*c2c66affSColin Finck # if !defined (_STLP_NO_MOVE_SEMANTIC)
170*c2c66affSColin Finck template <class _T1, class _T2>
171*c2c66affSColin Finck struct __move_traits<pair<_T1, _T2> >
172*c2c66affSColin Finck : _STLP_PRIV __move_traits_help1<_T1, _T2> {};
173*c2c66affSColin Finck # endif
174*c2c66affSColin Finck
175*c2c66affSColin Finck _STLP_END_NAMESPACE
176*c2c66affSColin Finck #endif
177*c2c66affSColin Finck
178*c2c66affSColin Finck #endif /* _STLP_INTERNAL_PAIR_H */
179*c2c66affSColin Finck
180*c2c66affSColin Finck // Local Variables:
181*c2c66affSColin Finck // mode:C++
182*c2c66affSColin Finck // End:
183