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