📄 mstl_pair.hpp
字号:
/*
The young Library
Copyright (c) 2005 by 杨桓
Permission to use, copy, modify, distribute and sell this software for any
purpose is hereby granted without fee, provided that the above copyright
notice appear in all copies and that both that copyright notice and this
permission notice appear in supporting documentation.
The author make no representations about the suitability of this software
for any purpose. It is provided "as is" without express or implied warranty.
*/
/*
* This file is derived from software bearing the following
* restrictions:
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this
* software and its documentation for any purpose is hereby
* granted without fee, provided that the above copyright notice
* appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
* Hewlett-Packard Company makes no representations about the
* suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*/
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#ifndef __MACRO_CPLUSPLUS_MINI_STL_PAIR_HEADER_FILE__
#define __MACRO_CPLUSPLUS_MINI_STL_PAIR_HEADER_FILE__
//-----------------------------------------------------------------------------
#include "mstl_define.hpp"
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_MINI_STL_BEGIN_NAMESPACE__
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
template< typename T1, typename T2 >
class pair
{
public:
typedef T1 first_type;
typedef T2 second_type;
typedef pair<T1, T2> self;
T1 first;
T2 second;
pair() : first(T1()), second(T2()) {}
pair( const T1& x, const T2& y ) : first(x), second(y) {}
template< typename U1, typename U2 >
pair( const U1& x, const U2& y ) : first(x), second(y) {}
template< typename U1, typename U2 >
pair( const pair<U1, U2>& rhs ) : first(rhs.first), second(rhs.second) {}
self& operator=( const self& rhs )
{
if( this != &rhs )
{
first = rhs.first;
second = rhs.second;
}
return *this;
}
template< typename U1, typename U2 >
self& operator=( const pair<U1, U2>& rhs )
{
if( this != &rhs )
{
first = rhs.first;
second = rhs.second;
}
return *this;
}
}; //end pair
template< typename T1, typename T2 >
inline pair<T1, T2> make_pair( const T1& x, const T2& y )
{
return pair<T1, T2>( x, y );
}
template< typename T1, typename T2 >
inline bool operator==( const pair<T1, T2>& lhs, const pair<T1, T2>& rhs )
{
return ( lhs.first == rhs.first && lhs.second == rhs.second );
}
template< typename T1, typename T2 >
inline bool operator!=( const pair<T1, T2>& lhs, const pair<T1, T2>& rhs )
{
return ( lhs.first != rhs.first || lhs.second != rhs.second );
}
template< typename T1, typename T2 >
inline bool operator<( const pair<T1, T2>& lhs, const pair<T1, T2>& rhs )
{
return ( lhs.first < rhs.first
|| ( !(rhs.first < lhs.first) && (lhs.second < rhs.second) ) );
}
template< typename T1, typename T2 >
inline bool operator>( const pair<T1,T2>& lhs, const pair<T1, T2>& rhs )
{
return ( rhs < lhs );
}
template< typename T1, typename T2 >
inline bool operator<=( const pair<T1, T2>& lhs, const pair<T1, T2>& rhs )
{
return !( rhs < lhs);
}
template< typename T1, typename T2 >
inline bool operator>=( const pair<T1, T2>& lhs, const pair<T1, T2>& rhs )
{
return !( lhs < rhs );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
__MACRO_CPLUSPLUS_MINI_STL_END_NAMESPACE__
#endif
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -