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