4 * Hewlett-Packard Company
6 * Copyright (c) 1996,1997
7 * Silicon Graphics Computer Systems, Inc.
10 * Moscow Center for SPARC Technology
15 * This material is provided "as is", with absolutely no warranty expressed
16 * or implied. Any use is at your own risk.
18 * Permission to use or copy this software for any purpose is hereby granted
19 * without fee, provided the above notices are retained on all copies.
20 * Permission to modify the code and to distribute modified code is granted,
21 * provided the above notices are retained, and a notice that the code was
22 * modified is included with the above copyright notice.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef _STLP_INTERNAL_PAIR_H
32 #define _STLP_INTERNAL_PAIR_H
34 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
35 # ifndef _STLP_TYPE_TRAITS_H
36 # include <stl/type_traits.h>
39 # if !defined (_STLP_MOVE_CONSTRUCT_FWK_H) && !defined (_STLP_NO_MOVE_SEMANTIC)
40 # include <stl/_move_construct_fwk.h>
46 template <class _T1
, class _T2
>
48 typedef _T1 first_type
;
49 typedef _T2 second_type
;
53 #if defined (_STLP_CONST_CONSTRUCTOR_BUG)
56 pair() : first(_T1()), second(_T2()) {}
58 pair(const _T1
& __a
, const _T2
& __b
) : first(__a
), second(__b
) {}
60 #if defined (_STLP_MEMBER_TEMPLATES)
61 template <class _U1
, class _U2
>
62 pair(const pair
<_U1
, _U2
>& __p
) : first(__p
.first
), second(__p
.second
) {}
64 pair(const pair
<_T1
,_T2
>& __o
) : first(__o
.first
), second(__o
.second
) {}
67 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)
68 pair(__move_source
<pair
<_T1
, _T2
> > src
) : first(_STLP_PRIV
_AsMoveSource(src
.get().first
)),
69 second(_STLP_PRIV
_AsMoveSource(src
.get().second
))
73 __TRIVIAL_DESTRUCTOR(pair
)
76 template <class _T1
, class _T2
>
77 inline bool _STLP_CALL
operator==(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
)
78 { return __x
.first
== __y
.first
&& __x
.second
== __y
.second
; }
80 template <class _T1
, class _T2
>
81 inline bool _STLP_CALL
operator<(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
) {
82 return __x
.first
< __y
.first
||
83 (!(__y
.first
< __x
.first
) && __x
.second
< __y
.second
);
86 #if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
87 template <class _T1
, class _T2
>
88 inline bool _STLP_CALL
operator!=(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
)
89 { return !(__x
== __y
); }
91 template <class _T1
, class _T2
>
92 inline bool _STLP_CALL
operator>(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
)
95 template <class _T1
, class _T2
>
96 inline bool _STLP_CALL
operator<=(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
)
97 { return !(__y
< __x
); }
99 template <class _T1
, class _T2
>
100 inline bool _STLP_CALL
operator>=(const pair
<_T1
, _T2
>& __x
, const pair
<_T1
, _T2
>& __y
)
101 { return !(__x
< __y
); }
102 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
104 #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
105 template <class _T1
, class _T2
, int _Sz
>
106 inline pair
<_T1
, _T2
const*> make_pair(_T1
const& __x
,
107 _T2
const (&__y
)[_Sz
])
108 { return pair
<_T1
, _T2
const*>(__x
, static_cast<_T2
const*>(__y
)); }
110 template <class _T1
, class _T2
, int _Sz
>
111 inline pair
<_T1
const*, _T2
> make_pair(_T1
const (&__x
)[_Sz
],
113 { return pair
<_T1
const*, _T2
>(static_cast<_T1
const*>(__x
), __y
); }
115 template <class _T1
, class _T2
, int _Sz1
, int _Sz2
>
116 inline pair
<_T1
const*, _T2
const*> make_pair(_T1
const (&__x
)[_Sz1
],
117 _T2
const (&__y
)[_Sz2
]) {
118 return pair
<_T1
const*, _T2
const*>(static_cast<_T1
const*>(__x
),
119 static_cast<_T2
const*>(__y
));
123 template <class _T1
, class _T2
>
124 inline pair
<_T1
, _T2
> _STLP_CALL
make_pair(_T1 __x
, _T2 __y
)
125 { return pair
<_T1
, _T2
>(__x
, __y
); }
129 #if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
130 _STLP_BEGIN_RELOPS_NAMESPACE
133 inline bool _STLP_CALL
operator!=(const _Tp
& __x
, const _Tp
& __y
)
134 { return !(__x
== __y
); }
137 inline bool _STLP_CALL
operator>(const _Tp
& __x
, const _Tp
& __y
)
138 { return __y
< __x
; }
141 inline bool _STLP_CALL
operator<=(const _Tp
& __x
, const _Tp
& __y
)
142 { return !(__y
< __x
); }
145 inline bool _STLP_CALL
operator>=(const _Tp
& __x
, const _Tp
& __y
)
146 { return !(__x
< __y
); }
148 _STLP_END_RELOPS_NAMESPACE
151 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
152 _STLP_BEGIN_NAMESPACE
154 template <class _T1
, class _T2
>
155 struct __type_traits
<pair
<_T1
, _T2
> > {
156 typedef __type_traits
<_T1
> _T1Traits
;
157 typedef __type_traits
<_T2
> _T2Traits
;
158 typedef typename _Land2
<typename
_T1Traits::has_trivial_default_constructor
,
159 typename
_T2Traits::has_trivial_default_constructor
>::_Ret has_trivial_default_constructor
;
160 typedef typename _Land2
<typename
_T1Traits::has_trivial_copy_constructor
,
161 typename
_T2Traits::has_trivial_copy_constructor
>::_Ret has_trivial_copy_constructor
;
162 typedef typename _Land2
<typename
_T1Traits::has_trivial_assignment_operator
,
163 typename
_T2Traits::has_trivial_assignment_operator
>::_Ret has_trivial_assignment_operator
;
164 typedef typename _Land2
<typename
_T1Traits::has_trivial_destructor
,
165 typename
_T2Traits::has_trivial_destructor
>::_Ret has_trivial_destructor
;
166 typedef __false_type is_POD_type
;
169 # if !defined (_STLP_NO_MOVE_SEMANTIC)
170 template <class _T1
, class _T2
>
171 struct __move_traits
<pair
<_T1
, _T2
> >
172 : _STLP_PRIV __move_traits_help1
<_T1
, _T2
> {};
178 #endif /* _STLP_INTERNAL_PAIR_H */