/home/ntakagi/work/STLport-5.1.5/stlport/stl/_pair.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996,1997
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 
00027 /* NOTE: This is an internal header file, included by other STL headers.
00028  *   You should not attempt to use it directly.
00029  */
00030 
00031 #ifndef _STLP_INTERNAL_PAIR_H
00032 #define _STLP_INTERNAL_PAIR_H
00033 
00034 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00035 #  include <stl/type_traits.h>
00036 #endif
00037 
00038 #ifndef _STLP_MOVE_CONSTRUCT_FWK_H
00039 #  include <stl/_move_construct_fwk.h>
00040 #endif
00041 
00042 _STLP_BEGIN_NAMESPACE
00043 
00044 template <class _T1, class _T2>
00045 struct pair {
00046   typedef _T1 first_type;
00047   typedef _T2 second_type;
00048 
00049   _T1 first;
00050   _T2 second;
00051 #if defined (_STLP_CONST_CONSTRUCTOR_BUG)
00052   pair() {}
00053 #else
00054   pair() : first(_T1()), second(_T2()) {}
00055 #endif
00056   pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
00057 
00058 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
00059   template <class _U1, class _U2>
00060   pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
00061 
00062   pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
00063 #endif
00064 
00065   pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)),
00066                                              second(_STLP_PRIV _AsMoveSource(src.get().second))
00067   {}
00068 
00069   __TRIVIAL_DESTRUCTOR(pair)
00070 };
00071 
00072 template <class _T1, class _T2>
00073 inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00074 { return __x.first == __y.first && __x.second == __y.second; }
00075 
00076 template <class _T1, class _T2>
00077 inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
00078   return __x.first < __y.first ||
00079          (!(__y.first < __x.first) && __x.second < __y.second);
00080 }
00081 
00082 #if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
00083 template <class _T1, class _T2>
00084 inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00085 { return !(__x == __y); }
00086 
00087 template <class _T1, class _T2>
00088 inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00089 { return __y < __x; }
00090 
00091 template <class _T1, class _T2>
00092 inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00093 { return !(__y < __x); }
00094 
00095 template <class _T1, class _T2>
00096 inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
00097 { return !(__x < __y); }
00098 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
00099 
00100 #if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
00101 template <class _T1, class _T2, int _Sz>
00102 inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
00103                                        _T2 const (&__y)[_Sz])
00104 { return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); }
00105 
00106 template <class _T1, class _T2, int _Sz>
00107 inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
00108                                        _T2 const& __y)
00109 { return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); }
00110 
00111 template <class _T1, class _T2, int _Sz1, int _Sz2>
00112 inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
00113                                               _T2 const (&__y)[_Sz2]) {
00114   return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
00115                                       static_cast<_T2 const*>(__y));
00116 }
00117 #endif
00118 
00119 template <class _T1, class _T2>
00120 inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y)
00121 { return pair<_T1, _T2>(__x, __y); }
00122 
00123 _STLP_END_NAMESPACE
00124 
00125 #if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
00126 _STLP_BEGIN_RELOPS_NAMESPACE
00127 
00128 template <class _Tp>
00129 inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y)
00130 { return !(__x == __y); }
00131 
00132 template <class _Tp>
00133 inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y)
00134 { return __y < __x; }
00135 
00136 template <class _Tp>
00137 inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y)
00138 { return !(__y < __x); }
00139 
00140 template <class _Tp>
00141 inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y)
00142 { return !(__x < __y); }
00143 
00144 _STLP_END_RELOPS_NAMESPACE
00145 #endif
00146 
00147 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00148 _STLP_BEGIN_NAMESPACE
00149 
00150 template <class _T1, class _T2>
00151 struct __type_traits<pair<_T1, _T2> > {
00152   typedef __type_traits<_T1> _T1Traits;
00153   typedef __type_traits<_T2> _T2Traits;
00154   typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor,
00155                           typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor;
00156   typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor,
00157                           typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor;
00158   typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator,
00159                           typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator;
00160   typedef typename _Land2<typename _T1Traits::has_trivial_destructor,
00161                           typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor;
00162   typedef __false_type is_POD_type;
00163 
00164 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
00165   // disable incorrect "dependent type qualifier" error
00166   typedef __false_type implemented;
00167 #endif
00168 };
00169 
00170 template <class _T1, class _T2>
00171 struct __move_traits<pair<_T1, _T2> >
00172   : _STLP_PRIV __move_traits_help1<_T1, _T2> {};
00173 
00174 _STLP_END_NAMESPACE
00175 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
00176 
00177 #endif /* _STLP_INTERNAL_PAIR_H */
00178 
00179 // Local Variables:
00180 // mode:C++
00181 // End:



Generated on Mon Mar 10 15:32:32 2008 by  doxygen 1.5.1