📄 tuple
字号:
tuple& operator=(const tuple& _Right)
{ // copy from _Right
_Impl = _Right._Impl;
return (*this);
}
template<_CLASS_FARG0_MAX>
tuple& operator=(const tuple<_FARG0_FARG1_MAX>& _Right)
{ // copy from _Right
_Impl = _Right._Impl;
return (*this);
}
template<class _Farg0,
class _Farg1>
tuple& operator=(const pair<_Farg0, _Farg1>& _Right)
{ // copy from _Right
_Impl._Value = _Right.first;
_Impl._Tail._Value = _Right.second;
_Impl._Tail._Tail._Value = _Nil_obj; // ensure size == 2
return (*this);
}
template<_CLASS_FARG0_MAX>
tuple(tuple<_FARG0_FARG1_MAX>& _Right)
: _Impl(_Right._Impl)
{ // copy _Right
}
template<_CLASS_FARG0_MAX>
tuple(tuple<_FARG0_FARG1_MAX>&& _Right)
: _Impl(_STD forward<typename tuple<_FARG0_FARG1_MAX>::_MyImpl>
(_Right._Impl))
{ // move _Right
}
template<class _Farg0,
class _Farg1>
tuple(pair<_Farg0, _Farg1>& _Right)
: _Impl(_Right.first,
_Right.second, _TAIL_2(_Nil_obj))
{ // copy _Right
}
template<class _Farg0,
class _Farg1>
tuple(pair<_Farg0, _Farg1>&& _Right)
: _Impl(_STD forward<_Farg0>(_Right.first),
_STD forward<_Farg1>(_Right.second), _TAIL_2(_Nil_obj))
{ // move _Right
}
tuple& operator=(tuple& _Right)
{ // copy from _Right
_Impl = _Right._Impl;
return (*this);
}
tuple& operator=(tuple&& _Right)
{ // copy from _Right
_Impl = _STD forward<_MyImpl>(_Right._Impl);
return (*this);
}
template<_CLASS_FARG0_MAX>
tuple& operator=(tuple<_FARG0_FARG1_MAX>& _Right)
{ // copy from _Right
_Impl = _Right._Impl;
return (*this);
}
template<_CLASS_FARG0_MAX>
tuple& operator=(tuple<_FARG0_FARG1_MAX>&& _Right)
{ // copy from _Right
_Impl = _STD forward<typename tuple<_FARG0_FARG1_MAX>::_MyImpl>
(_Right._Impl);
return (*this);
}
template<class _Farg0,
class _Farg1>
tuple& operator=(pair<_Farg0, _Farg1>& _Right)
{ // copy from _Right
_Impl._Value = _Right.first;
_Impl._Tail._Value = _Right.second;
_Impl._Tail._Tail._Value = _Nil_obj; // ensure size == 2
return (*this);
}
template<class _Farg0,
class _Farg1>
tuple& operator=(pair<_Farg0, _Farg1>&& _Right)
{ // copy from _Right
_Impl._Value = _STD forward<_Farg0>(_Right.first);
_Impl._Tail._Value = _STD forward<_Farg1>(_Right.second);
_Impl._Tail._Tail._Value = _Nil_obj; // ensure size == 2
return (*this);
}
void swap(_Myt& _Right)
{ // swap *this and _Right
_Impl.swap(_Right._Impl);
}
template<_CLASS_FARG0_MAX>
bool _Eq(const tuple<_FARG0_FARG1_MAX>& _Right) const
{ // return true if *this == _Right
return (_Impl._Eq(_Right._Impl));
}
template<_CLASS_FARG0_MAX>
bool _Lt(const tuple<_FARG0_FARG1_MAX>& _Right) const
{ // return true if *this < _Right
return (_Impl._Lt(_Right._Impl));
}
_MyImpl _Impl;
};
// TEMPLATE FUNCTION swap
template<_CLASS_ARG0_MAX> inline
void swap(
tuple<_ARG0_ARG1_MAX>& _Left,
tuple<_ARG0_ARG1_MAX>& _Right)
{ // swap _Left and _Right
_Left.swap(_Right);
}
template<> inline
void swap(tuple<>&, tuple<>&)
{ // swap empty tuples
}
// TEMPLATE operator==
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator==(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left == _Right
return (_Left._Eq(_Right));
}
template<> inline
bool operator==(const tuple<>&, const tuple<>&)
{ // return true for empty tuples
return (true);
}
// TEMPLATE operator!=
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator!=(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left != _Right
return (!_Left._Eq(_Right));
}
template<> inline
bool operator!=(const tuple<>&, const tuple<>&)
{ // return false for empty tuples
return (false);
}
// TEMPLATE operator<
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator<(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left < _Right
return (_Left._Lt(_Right));
}
template<> inline
bool operator<(const tuple<>&, const tuple<>&)
{ // return false for empty tuples
return (false);
}
// TEMPLATE operator<=
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator<=(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left <= _Right
return (!_Right._Lt(_Left));
}
template<> inline
bool operator<=(const tuple<>&, const tuple<>&)
{ // return true for empty tuples
return (true);
}
// TEMPLATE operator>
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator>(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left > _Right
return (_Right._Lt(_Left));
}
template<> inline
bool operator>(const tuple<>&, const tuple<>&)
{ // return false for empty tuples
return (false);
}
// TEMPLATE operator>=
template<_CLASS_ARG0_MAX,
_CLASS_FARG0_MAX> inline
bool operator>=(
const tuple<_ARG0_ARG1_MAX>& _Left,
const tuple<_FARG0_FARG1_MAX>& _Right)
{ // return _Left >= _Right
return (!_Left._Lt(_Right));
}
template<> inline
bool operator>=(const tuple<>&, const tuple<>&)
{ // return true for empty tuples
return (true);
}
// TEMPLATE STRUCT tuple_size
template<class _Tuple>
struct tuple_size
{ // struct to determine number of elements in tuple _Tuple
static const size_t value = _Size<typename _Tuple::_MyImpl>::_Value;
};
// TEMPLATE STRUCT tuple_element
template<size_t _Idx,
class _Tuple>
struct tuple_element
{ // struct to determine type of element _Idx in tuple _Tuple
typedef typename _Get<_Idx, typename _Tuple::_MyImpl>::_Type type;
};
// TEMPLATE FUNCTION get
template<size_t _Idx,
_CLASS_ARG0_MAX> inline
typename _Arg_traits<typename _Get<_Idx,
typename tuple<_ARG0_ARG1_MAX>::_MyImpl>::_Type>::_RType
get(tuple<_ARG0_ARG1_MAX>& _Tuple)
{ // return element at _Idx in tuple _Tuple
return (_Get<_Idx,
typename tuple<_ARG0_ARG1_MAX>::_MyImpl>::_Val(_Tuple._Impl));
}
template<size_t _Idx,
_CLASS_ARG0_MAX> inline
typename _Arg_traits<typename _Get<_Idx,
typename tuple<_ARG0_ARG1_MAX>::_MyImpl>::_Type>::_CType
get(const tuple<_ARG0_ARG1_MAX>& _Tuple)
{ // return element at _Idx in tuple _Tuple
return (_Get<_Idx,
typename tuple<_ARG0_ARG1_MAX>::_MyImpl>::_Val(_Tuple._Impl));
}
// STRUCT _Ignore
struct _Ignore
{ // class that ignores assignments
_Ignore()
{ // construct
}
template<class _Ty>
void operator=(const _Ty&) const
{ // do nothing
}
};
const _Ignore ignore;
// TEMPLATE STRUCT _Ttype
template<class _Ty>
struct _Ttype
{ // determine tuple element type for tuple returned by make_tuple
typedef _Ty _Type;
};
template<class _Ty>
struct _Ttype<reference_wrapper<_Ty> >
{ // determine tuple element type for tuple returned by make_tuple
typedef _Ty& _Type;
};
template<class _Ty>
struct _Ttype<const reference_wrapper<_Ty> >
{ // determine tuple element type for tuple returned by make_tuple
typedef _Ty& _Type;
};
template<class _Ty>
struct _Ttype<volatile reference_wrapper<_Ty> >
{ // determine tuple element type for tuple returned by make_tuple
typedef _Ty& _Type;
};
template<class _Ty>
struct _Ttype<const volatile reference_wrapper<_Ty> >
{ // determine tuple element type for tuple returned by make_tuple
typedef _Ty& _Type;
};
// TEMPLATE STRUCT _Make_tuple
template<_CLASS_ARG0_DEF_MAX>
struct _Make_tuple
{ // determine tuple element type for tuple returned by make_tuple
typedef tuple<_LIST15_MAX(typename _Ttype<_Arg, >::_Type)> _Type;
};
// TEMPLATE FUNCTION make_tuple, TEMPLATE FUNCTION tie
#define _INCL_FILE_xxtuple1
#include <xfwrap>
} // namespace tr1
_STD_END
_STD_BEGIN
#if _HAS_TR1_IMPORTS
using tr1::get;
using tr1::ignore;
using tr1::make_tuple;
using tr1::ref;
using tr1::tie;
using tr1::tuple;
using tr1::tuple_element;
using tr1::tuple_size;
#endif /* _HAS_TR1_IMPORTS */
#if _HAS_CPP0X
template<class _InIt> inline
_InIt begin(const tuple<_InIt, _InIt>& _Tuple)
{ // return first element of tuple
return (get<0>(_Tuple));
}
template<class _InIt> inline
_InIt end(const tuple<_InIt, _InIt>& _Tuple)
{ // return second element of tuple
return (get<1>(_Tuple));
}
#endif /* _HAS_CPP0X */
_STD_END
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _TUPLE_ */
/*
* Copyright (c) 1992-2009 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.20:0009 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -