williamr@4: /* williamr@4: * williamr@4: * Copyright (c) 1994 williamr@4: * Hewlett-Packard Company williamr@4: * williamr@4: * Copyright (c) 1996,1997 williamr@4: * Silicon Graphics Computer Systems, Inc. williamr@4: * williamr@4: * Copyright (c) 1997 williamr@4: * Moscow Center for SPARC Technology williamr@4: * williamr@4: * Copyright (c) 1999 williamr@4: * Boris Fomitchev williamr@4: * williamr@4: * This material is provided "as is", with absolutely no warranty expressed williamr@4: * or implied. Any use is at your own risk. williamr@4: * williamr@4: * Permission to use or copy this software for any purpose is hereby granted williamr@4: * without fee, provided the above notices are retained on all copies. williamr@4: * Permission to modify the code and to distribute modified code is granted, williamr@4: * provided the above notices are retained, and a notice that the code was williamr@4: * modified is included with the above copyright notice. williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: /* NOTE: This is an internal header file, included by other STL headers. williamr@4: * You should not attempt to use it directly. williamr@4: */ williamr@4: williamr@4: #ifndef _STLP_INTERNAL_PAIR_H williamr@4: #define _STLP_INTERNAL_PAIR_H williamr@4: williamr@4: #include williamr@4: williamr@4: _STLP_BEGIN_NAMESPACE williamr@4: williamr@4: #ifdef _STLP_USE_TRAP_LEAVE williamr@4: template williamr@4: struct pair { williamr@4: typedef _T1 first_type; williamr@4: typedef _T2 second_type; williamr@4: williamr@4: _T1 first; williamr@4: _STLP_StackPusher<_T1> __pusher; williamr@4: _T2 second; williamr@4: williamr@4: // first and second should construct themselves with their default constructors in ANSI order williamr@4: pair() : __pusher(&first) { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: williamr@4: pair(const _T1& __a, const _T2& __b) : first(__a), __pusher(&first), second(__b) { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: williamr@4: // undergroud extensions williamr@4: pair(const _T1& __a, __false_type) : first(__a), __pusher(&first), second() { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: pair(__true_type, const _T2& __a) : first(), __pusher(&first), second(__a) { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: williamr@4: #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200)) williamr@4: template williamr@4: pair(const pair<_U1, _U2>& __p) : first(__p.first), __pusher(&first), second(__p.second) { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: williamr@4: pair(const pair<_T1,_T2>& __o) : first(__o.first), __pusher(&first), second(__o.second) { williamr@4: CleanupStack::Pop(); williamr@4: } williamr@4: #endif williamr@4: __TRIVIAL_DESTRUCTOR(pair) williamr@4: }; williamr@4: williamr@4: #else williamr@4: williamr@4: template williamr@4: struct pair { williamr@4: typedef _T1 first_type; williamr@4: typedef _T2 second_type; williamr@4: williamr@4: _T1 first; williamr@4: _T2 second; williamr@4: # if defined (_STLP_CONST_CONSTRUCTOR_BUG) williamr@4: pair() {} williamr@4: # else williamr@4: pair() : first(_T1()), second(_T2()) {} williamr@4: # endif williamr@4: pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} williamr@4: williamr@4: // undergroud extensions williamr@4: pair(const _T1& __a, __false_type) : first(__a), second() {} williamr@4: pair(const _T2& __a, __true_type) : first(), second(__a) {} williamr@4: williamr@4: #if defined (_STLP_MEMBER_TEMPLATES) && !(defined (_STLP_MSVC) && (_STLP_MSVC < 1200)) williamr@4: template williamr@4: pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} williamr@4: williamr@4: pair(const pair<_T1,_T2>& __o) : first(__o.first), second(__o.second) {} williamr@4: #endif williamr@4: __TRIVIAL_DESTRUCTOR(pair) williamr@4: }; williamr@4: #endif williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) williamr@4: { williamr@4: return __x.first == __y.first && __x.second == __y.second; williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) williamr@4: { williamr@4: return __x.first < __y.first || williamr@4: (!(__y.first < __x.first) && __x.second < __y.second); williamr@4: } williamr@4: williamr@4: #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { williamr@4: return !(__x == __y); williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { williamr@4: return __y < __x; williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { williamr@4: return !(__y < __x); williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { williamr@4: return !(__x < __y); williamr@4: } williamr@4: williamr@4: #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */ williamr@4: williamr@4: williamr@4: #if defined(_STLP_FUNCTION_TMPL_PARTIAL_ORDER) && ! defined (_STLP_NO_EXTENSIONS) && ! defined (__BORLANDC__) && ! defined (__DMC__) williamr@4: template williamr@4: inline pair<_T1, _T2 const*> make_pair(_T1 const& __x, williamr@4: _T2 const (&__y)[_Sz]) williamr@4: { williamr@4: return pair<_T1, _T2 const*>(__x, static_cast<_T2 const*>(__y)); williamr@4: } williamr@4: williamr@4: template williamr@4: inline pair<_T1 const*, _T2> make_pair(_T1 const (&__x)[_Sz], williamr@4: _T2 const& __y) williamr@4: { williamr@4: return pair<_T1 const*, _T2>(static_cast<_T1 const*>(__x), __y); williamr@4: } williamr@4: williamr@4: template williamr@4: inline pair<_T1 const*, _T2 const*> make_pair(_T1 const (&__x)[_Sz1], williamr@4: _T2 const (&__y)[_Sz2]) williamr@4: { williamr@4: return pair<_T1 const*, _T2 const*>(static_cast<_T1 const*>(__x), williamr@4: static_cast<_T2 const*>(__y)); williamr@4: } williamr@4: #endif williamr@4: williamr@4: template williamr@4: inline pair<_T1, _T2> _STLP_CALL make_pair(const _T1& __x, const _T2& __y) williamr@4: { williamr@4: return pair<_T1, _T2>(__x, __y); williamr@4: } williamr@4: williamr@4: williamr@4: _STLP_END_NAMESPACE williamr@4: williamr@4: # if defined (_STLP_USE_NAMESPACES) || ! defined (_STLP_USE_SEPARATE_RELOPS_NAMESPACE) williamr@4: _STLP_BEGIN_RELOPS_NAMESPACE williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator!=(const _Tp& __x, const _Tp& __y) { williamr@4: return !(__x == __y); williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator>(const _Tp& __x, const _Tp& __y) { williamr@4: return __y < __x; williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator<=(const _Tp& __x, const _Tp& __y) { williamr@4: return !(__y < __x); williamr@4: } williamr@4: williamr@4: template williamr@4: inline bool _STLP_CALL operator>=(const _Tp& __x, const _Tp& __y) { williamr@4: return !(__x < __y); williamr@4: } williamr@4: williamr@4: _STLP_END_RELOPS_NAMESPACE williamr@4: williamr@4: # endif williamr@4: williamr@4: #endif /* _STLP_INTERNAL_PAIR_H */ williamr@4: williamr@4: // Local Variables: williamr@4: // mode:C++ williamr@4: // End: