epoc32/include/stdapis/stlportv5/stl/_pair.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_pair.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_pair.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -9,13 +9,13 @@
     1.4   * Copyright (c) 1997
     1.5   * Moscow Center for SPARC Technology
     1.6   *
     1.7 - * Copyright (c) 1999 
     1.8 + * Copyright (c) 1999
     1.9   * Boris Fomitchev
    1.10   *
    1.11   * This material is provided "as is", with absolutely no warranty expressed
    1.12   * or implied. Any use is at your own risk.
    1.13   *
    1.14 - * Permission to use or copy this software for any purpose is hereby granted 
    1.15 + * Permission to use or copy this software for any purpose is hereby granted
    1.16   * without fee, provided the above notices are retained on all copies.
    1.17   * Permission to modify the code and to distribute modified code is granted,
    1.18   * provided the above notices are retained, and a notice that the code was
    1.19 @@ -31,52 +31,16 @@
    1.20  #ifndef _STLP_INTERNAL_PAIR_H
    1.21  #define _STLP_INTERNAL_PAIR_H
    1.22  
    1.23 -#include <stl/_construct.h>
    1.24 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
    1.25 +#  include <stl/type_traits.h>
    1.26 +#endif
    1.27 +
    1.28 +#ifndef _STLP_MOVE_CONSTRUCT_FWK_H
    1.29 +#  include <stl/_move_construct_fwk.h>
    1.30 +#endif
    1.31  
    1.32  _STLP_BEGIN_NAMESPACE
    1.33  
    1.34 -#ifdef _STLP_USE_TRAP_LEAVE
    1.35 -template <class _T1, class _T2>
    1.36 -struct pair {
    1.37 -  typedef _T1 first_type;
    1.38 -  typedef _T2 second_type;
    1.39 -
    1.40 -  _T1 first;
    1.41 -  _STLP_StackPusher<_T1> __pusher;
    1.42 -  _T2 second;
    1.43 -
    1.44 -  // first and second should construct themselves with their default constructors in ANSI order
    1.45 -  pair() : __pusher(&first) {
    1.46 -    CleanupStack::Pop();
    1.47 -  }
    1.48 -
    1.49 -  pair(const _T1& __a, const _T2& __b) : first(__a), __pusher(&first), second(__b) {
    1.50 -    CleanupStack::Pop();
    1.51 -  }
    1.52 -
    1.53 -  // undergroud extensions
    1.54 -  pair(const _T1& __a, __false_type) : first(__a), __pusher(&first), second() {
    1.55 -    CleanupStack::Pop();
    1.56 -  }
    1.57 -  pair(__true_type, const _T2& __a) : first(), __pusher(&first), second(__a) {
    1.58 -    CleanupStack::Pop();
    1.59 -  }
    1.60 -
    1.61 -#if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
    1.62 -  template <class _U1, class _U2>
    1.63 -  pair(const pair<_U1, _U2>& __p) : first(__p.first), __pusher(&first), second(__p.second) {
    1.64 -    CleanupStack::Pop();
    1.65 -  }
    1.66 -
    1.67 -  pair(const pair<_T1,_T2>& __o) : first(__o.first), __pusher(&first), second(__o.second) {
    1.68 -    CleanupStack::Pop();
    1.69 -  }
    1.70 -#endif
    1.71 -  __TRIVIAL_DESTRUCTOR(pair)
    1.72 -};
    1.73 -
    1.74 -#else
    1.75 -
    1.76  template <class _T1, class _T2>
    1.77  struct pair {
    1.78    typedef _T1 first_type;
    1.79 @@ -84,124 +48,131 @@
    1.80  
    1.81    _T1 first;
    1.82    _T2 second;
    1.83 -# if defined (_STLP_CONST_CONSTRUCTOR_BUG)
    1.84 +#if defined (_STLP_CONST_CONSTRUCTOR_BUG)
    1.85    pair() {}
    1.86 -# else
    1.87 +#else
    1.88    pair() : first(_T1()), second(_T2()) {}
    1.89 -# endif
    1.90 +#endif
    1.91    pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
    1.92  
    1.93 -  // undergroud extensions
    1.94 -  pair(const _T1& __a, __false_type) : first(__a), second() {}
    1.95 -  pair(const _T2& __a, __true_type) : first(), second(__a) {}
    1.96 -
    1.97  #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
    1.98    template <class _U1, class _U2>
    1.99    pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
   1.100  
   1.101    pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
   1.102  #endif
   1.103 +
   1.104 +  pair(__move_source<pair<_T1, _T2> > src) : first(_STLP_PRIV _AsMoveSource(src.get().first)),
   1.105 +                                             second(_STLP_PRIV _AsMoveSource(src.get().second))
   1.106 +  {}
   1.107 +
   1.108    __TRIVIAL_DESTRUCTOR(pair)
   1.109  };
   1.110 -#endif
   1.111  
   1.112  template <class _T1, class _T2>
   1.113  inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.114 -{ 
   1.115 -  return __x.first == __y.first && __x.second == __y.second; 
   1.116 +{ return __x.first == __y.first && __x.second == __y.second; }
   1.117 +
   1.118 +template <class _T1, class _T2>
   1.119 +inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   1.120 +  return __x.first < __y.first ||
   1.121 +         (!(__y.first < __x.first) && __x.second < __y.second);
   1.122  }
   1.123  
   1.124 +#if defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
   1.125  template <class _T1, class _T2>
   1.126 -inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.127 -{ 
   1.128 -  return __x.first < __y.first || 
   1.129 -         (!(__y.first < __x.first) && __x.second < __y.second); 
   1.130 -}
   1.131 -
   1.132 -#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   1.133 +inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.134 +{ return !(__x == __y); }
   1.135  
   1.136  template <class _T1, class _T2>
   1.137 -inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   1.138 -  return !(__x == __y);
   1.139 -}
   1.140 +inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.141 +{ return __y < __x; }
   1.142  
   1.143  template <class _T1, class _T2>
   1.144 -inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   1.145 -  return __y < __x;
   1.146 -}
   1.147 +inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.148 +{ return !(__y < __x); }
   1.149  
   1.150  template <class _T1, class _T2>
   1.151 -inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   1.152 -  return !(__y < __x);
   1.153 -}
   1.154 -
   1.155 -template <class _T1, class _T2>
   1.156 -inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   1.157 -  return !(__x < __y);
   1.158 -}
   1.159 -
   1.160 +inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   1.161 +{ return !(__x < __y); }
   1.162  #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   1.163  
   1.164 -
   1.165 -#if defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && ! defined (_STLP_NO_EXTENSIONS) && ! defined (__BORLANDC__) && ! defined (__DMC__)
   1.166 +#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && !defined (_STLP_NO_EXTENSIONS)
   1.167  template <class _T1, class _T2, int _Sz>
   1.168  inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
   1.169                                         _T2 const (&__y)[_Sz])
   1.170 -{
   1.171 -  return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y));
   1.172 -}
   1.173 +{ return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); }
   1.174  
   1.175  template <class _T1, class _T2, int _Sz>
   1.176  inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
   1.177                                         _T2 const& __y)
   1.178 -{
   1.179 -  return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y);
   1.180 -}
   1.181 +{ return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); }
   1.182  
   1.183  template <class _T1, class _T2, int _Sz1, int _Sz2>
   1.184  inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
   1.185 -                                              _T2 const (&__y)[_Sz2])
   1.186 -{
   1.187 +                                              _T2 const (&__y)[_Sz2]) {
   1.188    return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
   1.189                                        static_cast<_T2 const*>(__y));
   1.190  }
   1.191  #endif
   1.192  
   1.193  template <class _T1, class _T2>
   1.194 -inline pair<_T1, _T2> _STLP_CALL make_pair(const _T1& __x, const _T2& __y)
   1.195 -{
   1.196 -  return pair<_T1, _T2>(__x, __y);
   1.197 -}
   1.198 -
   1.199 +inline pair<_T1, _T2> _STLP_CALL make_pair(_T1 __x, _T2 __y)
   1.200 +{ return pair<_T1, _T2>(__x, __y); }
   1.201  
   1.202  _STLP_END_NAMESPACE
   1.203  
   1.204 -# if defined (_STLP_USE_NAMESPACES) || ! defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) 
   1.205 +#if defined (_STLP_USE_NAMESPACES) || !defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE)
   1.206  _STLP_BEGIN_RELOPS_NAMESPACE
   1.207  
   1.208  template <class _Tp>
   1.209 -inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) {
   1.210 -  return !(__x == __y);
   1.211 -}
   1.212 +inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y)
   1.213 +{ return !(__x == __y); }
   1.214  
   1.215  template <class _Tp>
   1.216 -inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) {
   1.217 -  return __y < __x;
   1.218 -}
   1.219 +inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y)
   1.220 +{ return __y < __x; }
   1.221  
   1.222  template <class _Tp>
   1.223 -inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) {
   1.224 -  return !(__y < __x);
   1.225 -}
   1.226 +inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y)
   1.227 +{ return !(__y < __x); }
   1.228  
   1.229  template <class _Tp>
   1.230 -inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y) {
   1.231 -  return !(__x < __y);
   1.232 -}
   1.233 +inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y)
   1.234 +{ return !(__x < __y); }
   1.235  
   1.236  _STLP_END_RELOPS_NAMESPACE
   1.237 +#endif
   1.238  
   1.239 -# endif
   1.240 +#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
   1.241 +_STLP_BEGIN_NAMESPACE
   1.242 +
   1.243 +template <class _T1, class _T2>
   1.244 +struct __type_traits<pair<_T1, _T2> > {
   1.245 +  typedef __type_traits<_T1> _T1Traits;
   1.246 +  typedef __type_traits<_T2> _T2Traits;
   1.247 +  typedef typename _Land2<typename _T1Traits::has_trivial_default_constructor,
   1.248 +                          typename _T2Traits::has_trivial_default_constructor>::_Ret has_trivial_default_constructor;
   1.249 +  typedef typename _Land2<typename _T1Traits::has_trivial_copy_constructor,
   1.250 +                          typename _T2Traits::has_trivial_copy_constructor>::_Ret has_trivial_copy_constructor;
   1.251 +  typedef typename _Land2<typename _T1Traits::has_trivial_assignment_operator,
   1.252 +                          typename _T2Traits::has_trivial_assignment_operator>::_Ret has_trivial_assignment_operator;
   1.253 +  typedef typename _Land2<typename _T1Traits::has_trivial_destructor,
   1.254 +                          typename _T2Traits::has_trivial_destructor>::_Ret has_trivial_destructor;
   1.255 +  typedef __false_type is_POD_type;
   1.256 +
   1.257 +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x560)
   1.258 +  // disable incorrect "dependent type qualifier" error
   1.259 +  typedef __false_type implemented;
   1.260 +#endif
   1.261 +};
   1.262 +
   1.263 +template <class _T1, class _T2>
   1.264 +struct __move_traits<pair<_T1, _T2> >
   1.265 +  : _STLP_PRIV __move_traits_help1<_T1, _T2> {};
   1.266 +
   1.267 +_STLP_END_NAMESPACE
   1.268 +#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
   1.269  
   1.270  #endif /* _STLP_INTERNAL_PAIR_H */
   1.271