epoc32/include/stdapis/stlportv5/stl/_pair.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/stdapis/stlport/stl/_pair.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2  *
     3  * Copyright (c) 1994
     4  * Hewlett-Packard Company
     5  *
     6  * Copyright (c) 1996,1997
     7  * Silicon Graphics Computer Systems, Inc.
     8  *
     9  * Copyright (c) 1997
    10  * Moscow Center for SPARC Technology
    11  *
    12  * Copyright (c) 1999 
    13  * Boris Fomitchev
    14  *
    15  * This material is provided "as is", with absolutely no warranty expressed
    16  * or implied. Any use is at your own risk.
    17  *
    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.
    23  *
    24  */
    25 
    26 
    27 /* NOTE: This is an internal header file, included by other STL headers.
    28  *   You should not attempt to use it directly.
    29  */
    30 
    31 #ifndef _STLP_INTERNAL_PAIR_H
    32 #define _STLP_INTERNAL_PAIR_H
    33 
    34 #include <stl/_construct.h>
    35 
    36 _STLP_BEGIN_NAMESPACE
    37 
    38 #ifdef _STLP_USE_TRAP_LEAVE
    39 template <class _T1, class _T2>
    40 struct pair {
    41   typedef _T1 first_type;
    42   typedef _T2 second_type;
    43 
    44   _T1 first;
    45   _STLP_StackPusher<_T1> __pusher;
    46   _T2 second;
    47 
    48   // first and second should construct themselves with their default constructors in ANSI order
    49   pair() : __pusher(&first) {
    50     CleanupStack::Pop();
    51   }
    52 
    53   pair(const _T1& __a, const _T2& __b) : first(__a), __pusher(&first), second(__b) {
    54     CleanupStack::Pop();
    55   }
    56 
    57   // undergroud extensions
    58   pair(const _T1& __a, __false_type) : first(__a), __pusher(&first), second() {
    59     CleanupStack::Pop();
    60   }
    61   pair(__true_type, const _T2& __a) : first(), __pusher(&first), second(__a) {
    62     CleanupStack::Pop();
    63   }
    64 
    65 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
    66   template <class _U1, class _U2>
    67   pair(const pair<_U1, _U2>& __p) : first(__p.first), __pusher(&first), second(__p.second) {
    68     CleanupStack::Pop();
    69   }
    70 
    71   pair(const pair<_T1,_T2>& __o) : first(__o.first), __pusher(&first), second(__o.second) {
    72     CleanupStack::Pop();
    73   }
    74 #endif
    75   __TRIVIAL_DESTRUCTOR(pair)
    76 };
    77 
    78 #else
    79 
    80 template <class _T1, class _T2>
    81 struct pair {
    82   typedef _T1 first_type;
    83   typedef _T2 second_type;
    84 
    85   _T1 first;
    86   _T2 second;
    87 # if defined (_STLP_CONST_CONSTRUCTOR_BUG)
    88   pair() {}
    89 # else
    90   pair() : first(_T1()), second(_T2()) {}
    91 # endif
    92   pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
    93 
    94   // undergroud extensions
    95   pair(const _T1& __a, __false_type) : first(__a), second() {}
    96   pair(const _T2& __a, __true_type) : first(), second(__a) {}
    97 
    98 #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200))
    99   template <class _U1, class _U2>
   100   pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
   101 
   102   pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {}
   103 #endif
   104   __TRIVIAL_DESTRUCTOR(pair)
   105 };
   106 #endif
   107 
   108 template <class _T1, class _T2>
   109 inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   110 { 
   111   return __x.first == __y.first && __x.second == __y.second; 
   112 }
   113 
   114 template <class _T1, class _T2>
   115 inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
   116 { 
   117   return __x.first < __y.first || 
   118          (!(__y.first < __x.first) && __x.second < __y.second); 
   119 }
   120 
   121 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   122 
   123 template <class _T1, class _T2>
   124 inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   125   return !(__x == __y);
   126 }
   127 
   128 template <class _T1, class _T2>
   129 inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   130   return __y < __x;
   131 }
   132 
   133 template <class _T1, class _T2>
   134 inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   135   return !(__y < __x);
   136 }
   137 
   138 template <class _T1, class _T2>
   139 inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
   140   return !(__x < __y);
   141 }
   142 
   143 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   144 
   145 
   146 #if defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && ! defined (_STLP_NO_EXTENSIONS) && ! defined (__BORLANDC__) && ! defined (__DMC__)
   147 template <class _T1, class _T2, int _Sz>
   148 inline pair<_T1, _T2 const*> make_pair(_T1 const& __x,
   149                                        _T2 const (&__y)[_Sz])
   150 {
   151   return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y));
   152 }
   153 
   154 template <class _T1, class _T2, int _Sz>
   155 inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz],
   156                                        _T2 const& __y)
   157 {
   158   return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y);
   159 }
   160 
   161 template <class _T1, class _T2, int _Sz1, int _Sz2>
   162 inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1],
   163                                               _T2 const (&__y)[_Sz2])
   164 {
   165   return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x),
   166                                       static_cast<_T2 const*>(__y));
   167 }
   168 #endif
   169 
   170 template <class _T1, class _T2>
   171 inline pair<_T1, _T2> _STLP_CALL make_pair(const _T1& __x, const _T2& __y)
   172 {
   173   return pair<_T1, _T2>(__x, __y);
   174 }
   175 
   176 
   177 _STLP_END_NAMESPACE
   178 
   179 # if defined (_STLP_USE_NAMESPACES) || ! defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) 
   180 _STLP_BEGIN_RELOPS_NAMESPACE
   181 
   182 template <class _Tp>
   183 inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) {
   184   return !(__x == __y);
   185 }
   186 
   187 template <class _Tp>
   188 inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) {
   189   return __y < __x;
   190 }
   191 
   192 template <class _Tp>
   193 inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) {
   194   return !(__y < __x);
   195 }
   196 
   197 template <class _Tp>
   198 inline bool _STLP_CALL  operator>=(const _Tp& __x, const _Tp& __y) {
   199   return !(__x < __y);
   200 }
   201 
   202 _STLP_END_RELOPS_NAMESPACE
   203 
   204 # endif
   205 
   206 #endif /* _STLP_INTERNAL_PAIR_H */
   207 
   208 // Local Variables:
   209 // mode:C++
   210 // End: