2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===--------------------------- tuple ------------------------------------===//
|
|
|
|
//
|
2010-05-12 05:36:01 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_TUPLE
|
|
|
|
#define _LIBCPP_TUPLE
|
|
|
|
|
|
|
|
/*
|
|
|
|
tuple synopsis
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
template <class... T>
|
|
|
|
class tuple {
|
|
|
|
public:
|
|
|
|
constexpr tuple();
|
2013-07-23 00:02:19 +08:00
|
|
|
explicit tuple(const T&...); // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class... U>
|
2013-07-23 00:02:19 +08:00
|
|
|
explicit tuple(U&&...); // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple(const tuple&) = default;
|
2011-05-28 03:08:18 +08:00
|
|
|
tuple(tuple&&) = default;
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class... U>
|
2013-07-23 00:02:19 +08:00
|
|
|
tuple(const tuple<U...>&); // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class... U>
|
2013-07-23 00:02:19 +08:00
|
|
|
tuple(tuple<U...>&&); // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class U1, class U2>
|
2013-07-23 00:02:19 +08:00
|
|
|
tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class U1, class U2>
|
2013-07-23 00:02:19 +08:00
|
|
|
tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// allocator-extended constructors
|
|
|
|
template <class Alloc>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a);
|
|
|
|
template <class Alloc>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, const T&...);
|
|
|
|
template <class Alloc, class... U>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, U&&...);
|
|
|
|
template <class Alloc>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, const tuple&);
|
|
|
|
template <class Alloc>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, tuple&&);
|
|
|
|
template <class Alloc, class... U>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
|
|
|
|
template <class Alloc, class... U>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
|
|
|
|
template <class Alloc, class U1, class U2>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
|
|
|
|
template <class Alloc, class U1, class U2>
|
|
|
|
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
|
|
|
|
|
|
|
|
tuple& operator=(const tuple&);
|
2011-05-28 03:08:18 +08:00
|
|
|
tuple&
|
|
|
|
operator=(tuple&&) noexcept(AND(is_nothrow_move_assignable<T>::value ...));
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class... U>
|
|
|
|
tuple& operator=(const tuple<U...>&);
|
|
|
|
template <class... U>
|
|
|
|
tuple& operator=(tuple<U...>&&);
|
|
|
|
template <class U1, class U2>
|
|
|
|
tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
|
|
|
|
template <class U1, class U2>
|
|
|
|
tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
|
|
|
|
|
2011-05-28 03:08:18 +08:00
|
|
|
void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...));
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const unspecified ignore;
|
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
|
2013-10-06 02:46:37 +08:00
|
|
|
template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
|
2014-02-26 00:11:46 +08:00
|
|
|
template <class... T> tuple<T&...> tie(T&...) noexcept; // constexpr in C++14
|
2013-07-23 00:02:19 +08:00
|
|
|
template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14
|
2010-12-12 04:47:50 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// 20.4.1.4, tuple helper classes:
|
|
|
|
template <class T> class tuple_size; // undefined
|
|
|
|
template <class... T> class tuple_size<tuple<T...>>;
|
|
|
|
template <intsize_t I, class T> class tuple_element; // undefined
|
|
|
|
template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
|
2014-03-03 14:18:11 +08:00
|
|
|
template <size_t _Ip, class ..._Tp>
|
|
|
|
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// 20.4.1.5, element access:
|
2011-05-28 03:08:18 +08:00
|
|
|
template <intsize_t I, class... T>
|
|
|
|
typename tuple_element<I, tuple<T...>>::type&
|
2013-07-18 02:25:36 +08:00
|
|
|
get(tuple<T...>&) noexcept; // constexpr in C++14
|
2011-05-28 03:08:18 +08:00
|
|
|
template <intsize_t I, class... T>
|
2014-03-03 14:18:11 +08:00
|
|
|
typename const tuple_element<I, tuple<T...>>::type &
|
2013-07-18 02:25:36 +08:00
|
|
|
get(const tuple<T...>&) noexcept; // constexpr in C++14
|
2011-05-28 03:08:18 +08:00
|
|
|
template <intsize_t I, class... T>
|
|
|
|
typename tuple_element<I, tuple<T...>>::type&&
|
2013-07-18 02:25:36 +08:00
|
|
|
get(tuple<T...>&&) noexcept; // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2013-07-13 10:54:05 +08:00
|
|
|
template <class T1, class... T>
|
|
|
|
constexpr T1& get(tuple<T...>&) noexcept; // C++14
|
|
|
|
template <class T1, class... T>
|
|
|
|
constexpr T1 const& get(const tuple<T...>&) noexcept; // C++14
|
|
|
|
template <class T1, class... T>
|
|
|
|
constexpr T1&& get(tuple<T...>&&) noexcept; // C++14
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// 20.4.1.6, relational operators:
|
2013-07-23 00:02:19 +08:00
|
|
|
template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
|
|
|
template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
|
|
|
template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
|
|
|
template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
|
|
|
template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
|
|
|
template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class... Types, class Alloc>
|
|
|
|
struct uses_allocator<tuple<Types...>, Alloc>;
|
|
|
|
|
|
|
|
template <class... Types>
|
2011-05-28 03:08:18 +08:00
|
|
|
void
|
|
|
|
swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y)));
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <__config>
|
|
|
|
#include <__tuple>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <type_traits>
|
2011-12-20 01:58:44 +08:00
|
|
|
#include <__functional_base>
|
|
|
|
#include <utility>
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2010-05-12 03:42:16 +08:00
|
|
|
#pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_HAS_NO_VARIADICS
|
|
|
|
|
|
|
|
// tuple_size
|
|
|
|
|
|
|
|
template <class ..._Tp>
|
2013-08-13 02:38:34 +08:00
|
|
|
class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> >
|
2010-05-12 03:42:16 +08:00
|
|
|
: public integral_constant<size_t, sizeof...(_Tp)>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
// tuple_element
|
|
|
|
|
|
|
|
template <size_t _Ip, class ..._Tp>
|
2013-08-13 02:38:34 +08:00
|
|
|
class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> >
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2011-01-25 00:07:25 +08:00
|
|
|
typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
2014-03-03 14:18:11 +08:00
|
|
|
#if _LIBCPP_STD_VER > 11
|
|
|
|
template <size_t _Ip, class ..._Tp>
|
|
|
|
using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// __tuple_leaf
|
|
|
|
|
2011-12-12 04:31:33 +08:00
|
|
|
template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
|
|
|
|
#if __has_feature(is_final)
|
|
|
|
&& !__is_final(_Hp)
|
|
|
|
#endif
|
|
|
|
>
|
2010-05-12 03:42:16 +08:00
|
|
|
class __tuple_leaf;
|
|
|
|
|
|
|
|
template <size_t _Ip, class _Hp, bool _Ep>
|
2010-09-24 02:58:28 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
|
2011-05-28 03:08:18 +08:00
|
|
|
_NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
swap(__x.get(), __y.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t _Ip, class _Hp, bool>
|
|
|
|
class __tuple_leaf
|
|
|
|
{
|
|
|
|
_Hp value;
|
|
|
|
|
|
|
|
__tuple_leaf& operator=(const __tuple_leaf&);
|
|
|
|
public:
|
2012-07-07 04:50:27 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
|
|
|
|
_NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : value()
|
2010-05-12 03:42:16 +08:00
|
|
|
{static_assert(!is_reference<_Hp>::value,
|
|
|
|
"Attempted to default construct a reference element in a tuple");}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 0>, const _Alloc&)
|
|
|
|
: value()
|
|
|
|
{static_assert(!is_reference<_Hp>::value,
|
|
|
|
"Attempted to default construct a reference element in a tuple");}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
|
|
|
|
: value(allocator_arg_t(), __a)
|
|
|
|
{static_assert(!is_reference<_Hp>::value,
|
|
|
|
"Attempted to default construct a reference element in a tuple");}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
|
|
|
|
: value(__a)
|
|
|
|
{static_assert(!is_reference<_Hp>::value,
|
|
|
|
"Attempted to default construct a reference element in a tuple");}
|
|
|
|
|
2010-09-28 01:54:17 +08:00
|
|
|
template <class _Tp,
|
2014-07-25 02:48:34 +08:00
|
|
|
class = typename enable_if<
|
|
|
|
__lazy_and<
|
|
|
|
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
|
|
|
, is_constructible<_Hp, _Tp>
|
|
|
|
>::value
|
|
|
|
>::type
|
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-07-07 05:53:48 +08:00
|
|
|
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
2011-07-01 05:18:19 +08:00
|
|
|
: value(_VSTD::forward<_Tp>(__t))
|
2010-09-28 01:54:17 +08:00
|
|
|
{static_assert(!is_reference<_Hp>::value ||
|
2011-12-02 04:21:04 +08:00
|
|
|
(is_lvalue_reference<_Hp>::value &&
|
2010-05-12 03:42:16 +08:00
|
|
|
(is_lvalue_reference<_Tp>::value ||
|
|
|
|
is_same<typename remove_reference<_Tp>::type,
|
|
|
|
reference_wrapper<
|
|
|
|
typename remove_reference<_Hp>::type
|
|
|
|
>
|
2011-12-02 04:21:04 +08:00
|
|
|
>::value)) ||
|
2010-09-28 01:54:17 +08:00
|
|
|
(is_rvalue_reference<_Hp>::value &&
|
|
|
|
!is_lvalue_reference<_Tp>::value),
|
2010-05-12 03:42:16 +08:00
|
|
|
"Attempted to construct a reference element in a tuple with an rvalue");}
|
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: value(_VSTD::forward<_Tp>(__t))
|
2010-05-12 03:42:16 +08:00
|
|
|
{static_assert(!is_lvalue_reference<_Hp>::value ||
|
2011-12-02 04:21:04 +08:00
|
|
|
(is_lvalue_reference<_Hp>::value &&
|
2010-05-12 03:42:16 +08:00
|
|
|
(is_lvalue_reference<_Tp>::value ||
|
|
|
|
is_same<typename remove_reference<_Tp>::type,
|
|
|
|
reference_wrapper<
|
|
|
|
typename remove_reference<_Hp>::type
|
|
|
|
>
|
2011-12-02 04:21:04 +08:00
|
|
|
>::value)),
|
2010-05-12 03:42:16 +08:00
|
|
|
"Attempted to construct a reference element in a tuple with an rvalue");}
|
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: value(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t))
|
2010-05-12 03:42:16 +08:00
|
|
|
{static_assert(!is_lvalue_reference<_Hp>::value ||
|
2011-12-02 04:21:04 +08:00
|
|
|
(is_lvalue_reference<_Hp>::value &&
|
2010-05-12 03:42:16 +08:00
|
|
|
(is_lvalue_reference<_Tp>::value ||
|
|
|
|
is_same<typename remove_reference<_Tp>::type,
|
|
|
|
reference_wrapper<
|
|
|
|
typename remove_reference<_Hp>::type
|
|
|
|
>
|
2011-12-02 04:21:04 +08:00
|
|
|
>::value)),
|
2010-05-12 03:42:16 +08:00
|
|
|
"Attempted to construct a reference element in a tuple with an rvalue");}
|
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: value(_VSTD::forward<_Tp>(__t), __a)
|
2010-05-12 03:42:16 +08:00
|
|
|
{static_assert(!is_lvalue_reference<_Hp>::value ||
|
2011-12-02 04:21:04 +08:00
|
|
|
(is_lvalue_reference<_Hp>::value &&
|
2010-05-12 03:42:16 +08:00
|
|
|
(is_lvalue_reference<_Tp>::value ||
|
|
|
|
is_same<typename remove_reference<_Tp>::type,
|
|
|
|
reference_wrapper<
|
|
|
|
typename remove_reference<_Hp>::type
|
|
|
|
>
|
2011-12-02 04:21:04 +08:00
|
|
|
>::value)),
|
2010-05-12 03:42:16 +08:00
|
|
|
"Attempted to construct a reference element in a tuple with an rvalue");}
|
|
|
|
|
2014-04-22 07:48:09 +08:00
|
|
|
__tuple_leaf(const __tuple_leaf& __t) = default;
|
|
|
|
__tuple_leaf(__tuple_leaf&& __t) = default;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf&
|
2012-07-07 05:53:48 +08:00
|
|
|
operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
value = _VSTD::forward<_Tp>(__t);
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-28 03:08:18 +08:00
|
|
|
int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::swap(*this, __t);
|
2010-05-12 03:42:16 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return value;}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return value;}
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <size_t _Ip, class _Hp>
|
|
|
|
class __tuple_leaf<_Ip, _Hp, true>
|
|
|
|
: private _Hp
|
|
|
|
{
|
|
|
|
|
|
|
|
__tuple_leaf& operator=(const __tuple_leaf&);
|
|
|
|
public:
|
2012-07-07 04:50:27 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf()
|
|
|
|
_NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
|
|
|
|
: _Hp(allocator_arg_t(), __a) {}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
|
|
|
|
: _Hp(__a) {}
|
|
|
|
|
2010-09-28 01:54:17 +08:00
|
|
|
template <class _Tp,
|
2014-07-25 02:48:34 +08:00
|
|
|
class = typename enable_if<
|
|
|
|
__lazy_and<
|
|
|
|
__lazy_not<is_same<typename decay<_Tp>::type, __tuple_leaf>>
|
|
|
|
, is_constructible<_Hp, _Tp>
|
|
|
|
>::value
|
|
|
|
>::type
|
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-07-07 05:53:48 +08:00
|
|
|
explicit __tuple_leaf(_Tp&& __t) _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
|
2011-07-01 05:18:19 +08:00
|
|
|
: _Hp(_VSTD::forward<_Tp>(__t)) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: _Hp(_VSTD::forward<_Tp>(__t)) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: _Hp(allocator_arg_t(), __a, _VSTD::forward<_Tp>(__t)) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp, class _Alloc>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: _Hp(_VSTD::forward<_Tp>(__t), __a) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2014-07-25 02:48:34 +08:00
|
|
|
__tuple_leaf(__tuple_leaf const &) = default;
|
|
|
|
__tuple_leaf(__tuple_leaf &&) = default;
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Tp>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_leaf&
|
2012-07-07 05:53:48 +08:00
|
|
|
operator=(_Tp&& __t) _NOEXCEPT_((is_nothrow_assignable<_Hp&, _Tp>::value))
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
_Hp::operator=(_VSTD::forward<_Tp>(__t));
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2011-05-28 03:08:18 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
int
|
|
|
|
swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::swap(*this, __t);
|
2010-05-12 03:42:16 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);}
|
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);}
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
2010-09-24 02:58:28 +08:00
|
|
|
template <class ..._Tp>
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 05:53:48 +08:00
|
|
|
void __swallow(_Tp&&...) _NOEXCEPT {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2014-11-26 05:57:41 +08:00
|
|
|
template <bool ..._Pred>
|
2014-10-15 18:33:02 +08:00
|
|
|
struct __all
|
2014-11-26 05:57:41 +08:00
|
|
|
: is_same<__all<_Pred...>, __all<(_Pred, true)...>>
|
2014-10-15 18:33:02 +08:00
|
|
|
{ };
|
2011-05-28 03:08:18 +08:00
|
|
|
|
2014-10-15 18:33:02 +08:00
|
|
|
template <class _Tp>
|
|
|
|
struct __all_default_constructible;
|
2011-05-28 03:08:18 +08:00
|
|
|
|
2014-10-15 18:33:02 +08:00
|
|
|
template <class ..._Tp>
|
|
|
|
struct __all_default_constructible<__tuple_types<_Tp...>>
|
|
|
|
: __all<is_default_constructible<_Tp>::value...>
|
|
|
|
{ };
|
2011-05-28 03:08:18 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// __tuple_impl
|
|
|
|
|
|
|
|
template<class _Indx, class ..._Tp> struct __tuple_impl;
|
|
|
|
|
|
|
|
template<size_t ..._Indx, class ..._Tp>
|
|
|
|
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
|
|
|
|
: public __tuple_leaf<_Indx, _Tp>...
|
|
|
|
{
|
2012-07-07 04:39:45 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 04:50:27 +08:00
|
|
|
_LIBCPP_CONSTEXPR __tuple_impl()
|
|
|
|
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
|
2012-07-07 04:39:45 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <size_t ..._Uf, class ..._Tf,
|
|
|
|
size_t ..._Ul, class ..._Tl, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
explicit
|
|
|
|
__tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
|
|
|
|
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
|
2012-07-07 05:53:48 +08:00
|
|
|
_Up&&... __u)
|
|
|
|
_NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
|
|
|
|
__all<is_nothrow_default_constructible<_Tl>::value...>::value)) :
|
2011-07-01 05:18:19 +08:00
|
|
|
__tuple_leaf<_Uf, _Tf>(_VSTD::forward<_Up>(__u))...,
|
2010-05-12 03:42:16 +08:00
|
|
|
__tuple_leaf<_Ul, _Tl>()...
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <class _Alloc, size_t ..._Uf, class ..._Tf,
|
|
|
|
size_t ..._Ul, class ..._Tl, class ..._Up>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
explicit
|
|
|
|
__tuple_impl(allocator_arg_t, const _Alloc& __a,
|
|
|
|
__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
|
|
|
|
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
|
|
|
|
_Up&&... __u) :
|
|
|
|
__tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::forward<_Up>(__u))...,
|
2010-05-12 03:42:16 +08:00
|
|
|
__tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
|
|
|
|
{}
|
|
|
|
|
|
|
|
template <class _Tuple,
|
|
|
|
class = typename enable_if
|
|
|
|
<
|
2013-04-14 08:01:13 +08:00
|
|
|
__tuple_constructible<_Tuple, tuple<_Tp...> >::value
|
2010-05-12 03:42:16 +08:00
|
|
|
>::type
|
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-07-07 05:53:48 +08:00
|
|
|
__tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx,
|
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
|
2011-07-01 05:18:19 +08:00
|
|
|
: __tuple_leaf<_Indx, _Tp>(_VSTD::forward<typename tuple_element<_Indx,
|
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
|
2010-05-12 03:42:16 +08:00
|
|
|
{}
|
|
|
|
|
|
|
|
template <class _Alloc, class _Tuple,
|
|
|
|
class = typename enable_if
|
|
|
|
<
|
2011-01-25 00:07:25 +08:00
|
|
|
__tuple_convertible<_Tuple, tuple<_Tp...> >::value
|
2010-05-12 03:42:16 +08:00
|
|
|
>::type
|
|
|
|
>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
__tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
|
|
|
|
: __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
|
2010-08-22 08:02:43 +08:00
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>(), __a,
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::forward<typename tuple_element<_Indx,
|
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...
|
2010-05-12 03:42:16 +08:00
|
|
|
{}
|
|
|
|
|
|
|
|
template <class _Tuple>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
typename enable_if
|
|
|
|
<
|
2011-01-25 00:07:25 +08:00
|
|
|
__tuple_assignable<_Tuple, tuple<_Tp...> >::value,
|
2010-05-12 03:42:16 +08:00
|
|
|
__tuple_impl&
|
|
|
|
>::type
|
2012-07-07 05:53:48 +08:00
|
|
|
operator=(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_assignable<_Tp&, typename tuple_element<_Indx,
|
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<typename tuple_element<_Indx,
|
|
|
|
typename __make_tuple_types<_Tuple>::type>::type>(_VSTD::get<_Indx>(__t)))...);
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2013-11-07 01:45:43 +08:00
|
|
|
__tuple_impl(const __tuple_impl&) = default;
|
|
|
|
__tuple_impl(__tuple_impl&&) = default;
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_impl&
|
|
|
|
operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value))
|
|
|
|
{
|
|
|
|
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
__tuple_impl&
|
|
|
|
operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value))
|
|
|
|
{
|
|
|
|
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
|
|
|
|
return *this;
|
|
|
|
}
|
2012-02-16 04:13:52 +08:00
|
|
|
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
void swap(__tuple_impl& __t)
|
2011-05-28 03:08:18 +08:00
|
|
|
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Tp>
|
2013-08-13 02:38:34 +08:00
|
|
|
class _LIBCPP_TYPE_VIS_ONLY tuple
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
|
|
|
|
|
|
|
|
base base_;
|
|
|
|
|
2013-07-18 02:25:36 +08:00
|
|
|
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-12-02 04:21:04 +08:00
|
|
|
typename tuple_element<_Jp, tuple<_Up...> >::type& get(tuple<_Up...>&) _NOEXCEPT;
|
2013-07-18 02:25:36 +08:00
|
|
|
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-12-02 04:21:04 +08:00
|
|
|
const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT;
|
2013-07-18 02:25:36 +08:00
|
|
|
template <size_t _Jp, class ..._Up> friend _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-12-02 04:21:04 +08:00
|
|
|
typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT;
|
2010-05-12 03:42:16 +08:00
|
|
|
public:
|
|
|
|
|
2014-10-15 18:33:02 +08:00
|
|
|
template <bool _Dummy = true, class _Up = typename enable_if<
|
|
|
|
__all<(_Dummy && is_default_constructible<_Tp>::value)...>::value
|
|
|
|
>::type>
|
2012-07-07 04:39:45 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 04:50:27 +08:00
|
|
|
_LIBCPP_CONSTEXPR tuple()
|
|
|
|
_NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
|
2012-07-07 04:39:45 +08:00
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-07-07 05:53:48 +08:00
|
|
|
explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all<is_nothrow_copy_constructible<_Tp>::value...>::value))
|
2010-05-12 03:42:16 +08:00
|
|
|
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
|
|
|
|
typename __make_tuple_indices<0>::type(),
|
|
|
|
typename __make_tuple_types<tuple, 0>::type(),
|
|
|
|
__t...
|
|
|
|
) {}
|
|
|
|
|
|
|
|
template <class _Alloc>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
|
|
|
|
: base_(allocator_arg_t(), __a,
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
|
|
|
|
typename __make_tuple_indices<0>::type(),
|
|
|
|
typename __make_tuple_types<tuple, 0>::type(),
|
|
|
|
__t...
|
|
|
|
) {}
|
|
|
|
|
|
|
|
template <class ..._Up,
|
2012-04-02 07:10:42 +08:00
|
|
|
typename enable_if
|
2010-05-12 03:42:16 +08:00
|
|
|
<
|
|
|
|
sizeof...(_Up) <= sizeof...(_Tp) &&
|
|
|
|
__tuple_convertible
|
|
|
|
<
|
|
|
|
tuple<_Up...>,
|
|
|
|
typename __make_tuple_types<tuple,
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2014-10-15 18:33:02 +08:00
|
|
|
>::value &&
|
|
|
|
__all_default_constructible<
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2012-04-02 07:10:42 +08:00
|
|
|
>::value,
|
|
|
|
bool
|
|
|
|
>::type = false
|
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-04-02 07:10:42 +08:00
|
|
|
tuple(_Up&&... __u)
|
2012-07-07 05:53:48 +08:00
|
|
|
_NOEXCEPT_((
|
2014-09-17 01:08:21 +08:00
|
|
|
is_nothrow_constructible<base,
|
2012-07-07 05:53:48 +08:00
|
|
|
typename __make_tuple_indices<sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
|
2014-09-17 01:08:21 +08:00
|
|
|
_Up...
|
2012-07-07 05:53:48 +08:00
|
|
|
>::value
|
|
|
|
))
|
2012-04-02 07:10:42 +08:00
|
|
|
: base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
|
|
|
|
_VSTD::forward<_Up>(__u)...) {}
|
|
|
|
|
|
|
|
template <class ..._Up,
|
|
|
|
typename enable_if
|
|
|
|
<
|
|
|
|
sizeof...(_Up) <= sizeof...(_Tp) &&
|
|
|
|
__tuple_constructible
|
|
|
|
<
|
|
|
|
tuple<_Up...>,
|
|
|
|
typename __make_tuple_types<tuple,
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
|
|
|
>::value &&
|
|
|
|
!__tuple_convertible
|
|
|
|
<
|
|
|
|
tuple<_Up...>,
|
|
|
|
typename __make_tuple_types<tuple,
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2014-10-15 18:33:02 +08:00
|
|
|
>::value &&
|
|
|
|
__all_default_constructible<
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2012-04-02 07:10:42 +08:00
|
|
|
>::value,
|
|
|
|
bool
|
|
|
|
>::type =false
|
2010-05-12 03:42:16 +08:00
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
explicit
|
|
|
|
tuple(_Up&&... __u)
|
2012-07-07 05:53:48 +08:00
|
|
|
_NOEXCEPT_((
|
2014-09-17 01:08:21 +08:00
|
|
|
is_nothrow_constructible<base,
|
2012-07-07 05:53:48 +08:00
|
|
|
typename __make_tuple_indices<sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type,
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type,
|
|
|
|
_Up...
|
|
|
|
>::value
|
|
|
|
))
|
2010-05-12 03:42:16 +08:00
|
|
|
: base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::forward<_Up>(__u)...) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Alloc, class ..._Up,
|
|
|
|
class = typename enable_if
|
|
|
|
<
|
|
|
|
sizeof...(_Up) <= sizeof...(_Tp) &&
|
|
|
|
__tuple_convertible
|
|
|
|
<
|
|
|
|
tuple<_Up...>,
|
|
|
|
typename __make_tuple_types<tuple,
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2014-10-15 18:33:02 +08:00
|
|
|
>::value &&
|
|
|
|
__all_default_constructible<
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp),
|
|
|
|
sizeof...(_Up) < sizeof...(_Tp) ?
|
|
|
|
sizeof...(_Up) :
|
|
|
|
sizeof...(_Tp)>::type
|
2010-05-12 03:42:16 +08:00
|
|
|
>::value
|
|
|
|
>::type
|
|
|
|
>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
|
|
|
|
: base_(allocator_arg_t(), __a,
|
|
|
|
typename __make_tuple_indices<sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
|
|
|
|
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::forward<_Up>(__u)...) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tuple,
|
2012-04-02 07:10:42 +08:00
|
|
|
typename enable_if
|
2010-05-12 03:42:16 +08:00
|
|
|
<
|
2012-04-02 07:10:42 +08:00
|
|
|
__tuple_convertible<_Tuple, tuple>::value,
|
|
|
|
bool
|
|
|
|
>::type = false
|
2010-05-12 03:42:16 +08:00
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
|
2011-07-01 05:18:19 +08:00
|
|
|
: base_(_VSTD::forward<_Tuple>(__t)) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2012-04-02 07:10:42 +08:00
|
|
|
template <class _Tuple,
|
|
|
|
typename enable_if
|
|
|
|
<
|
|
|
|
__tuple_constructible<_Tuple, tuple>::value &&
|
|
|
|
!__tuple_convertible<_Tuple, tuple>::value,
|
|
|
|
bool
|
|
|
|
>::type = false
|
|
|
|
>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2012-04-02 07:10:42 +08:00
|
|
|
explicit
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(_Tuple&& __t) _NOEXCEPT_((is_nothrow_constructible<base, _Tuple>::value))
|
2012-04-02 07:10:42 +08:00
|
|
|
: base_(_VSTD::forward<_Tuple>(__t)) {}
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc, class _Tuple,
|
|
|
|
class = typename enable_if
|
|
|
|
<
|
|
|
|
__tuple_convertible<_Tuple, tuple>::value
|
|
|
|
>::type
|
|
|
|
>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
|
2011-07-01 05:18:19 +08:00
|
|
|
: base_(allocator_arg_t(), __a, _VSTD::forward<_Tuple>(__t)) {}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tuple,
|
|
|
|
class = typename enable_if
|
|
|
|
<
|
|
|
|
__tuple_assignable<_Tuple, tuple>::value
|
|
|
|
>::type
|
|
|
|
>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple&
|
2012-07-07 05:53:48 +08:00
|
|
|
operator=(_Tuple&& __t) _NOEXCEPT_((is_nothrow_assignable<base&, _Tuple>::value))
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
base_.operator=(_VSTD::forward<_Tuple>(__t));
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-28 03:08:18 +08:00
|
|
|
void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
|
|
|
|
{base_.swap(__t.base_);}
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
2013-08-13 02:38:34 +08:00
|
|
|
class _LIBCPP_TYPE_VIS_ONLY tuple<>
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
public:
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 04:50:27 +08:00
|
|
|
_LIBCPP_CONSTEXPR tuple() _NOEXCEPT {}
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _Alloc>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc&, const tuple&) _NOEXCEPT {}
|
2011-11-30 02:15:50 +08:00
|
|
|
template <class _Up>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(array<_Up, 0>) _NOEXCEPT {}
|
2011-11-30 02:15:50 +08:00
|
|
|
template <class _Alloc, class _Up>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-07-07 05:53:48 +08:00
|
|
|
tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {}
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2011-05-28 03:08:18 +08:00
|
|
|
void swap(tuple&) _NOEXCEPT {}
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Tp>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2011-06-02 03:59:32 +08:00
|
|
|
typename enable_if
|
|
|
|
<
|
|
|
|
__all<__is_swappable<_Tp>::value...>::value,
|
|
|
|
void
|
|
|
|
>::type
|
2011-05-28 03:08:18 +08:00
|
|
|
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
|
|
|
|
_NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value)
|
|
|
|
{__t.swap(__u);}
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// get
|
|
|
|
|
|
|
|
template <size_t _Ip, class ..._Tp>
|
2013-07-18 02:25:36 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-01-25 00:07:25 +08:00
|
|
|
typename tuple_element<_Ip, tuple<_Tp...> >::type&
|
2011-12-02 04:21:04 +08:00
|
|
|
get(tuple<_Tp...>& __t) _NOEXCEPT
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-01-25 00:07:25 +08:00
|
|
|
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
|
2010-05-12 03:42:16 +08:00
|
|
|
return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t _Ip, class ..._Tp>
|
2013-07-18 02:25:36 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-01-25 00:07:25 +08:00
|
|
|
const typename tuple_element<_Ip, tuple<_Tp...> >::type&
|
2011-12-02 04:21:04 +08:00
|
|
|
get(const tuple<_Tp...>& __t) _NOEXCEPT
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2011-01-25 00:07:25 +08:00
|
|
|
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
|
2010-05-12 03:42:16 +08:00
|
|
|
return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
|
|
|
|
}
|
|
|
|
|
2010-11-18 03:52:17 +08:00
|
|
|
template <size_t _Ip, class ..._Tp>
|
2013-07-18 02:25:36 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2011-01-25 00:07:25 +08:00
|
|
|
typename tuple_element<_Ip, tuple<_Tp...> >::type&&
|
2011-12-02 04:21:04 +08:00
|
|
|
get(tuple<_Tp...>&& __t) _NOEXCEPT
|
2010-11-18 03:52:17 +08:00
|
|
|
{
|
2011-01-25 00:07:25 +08:00
|
|
|
typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type;
|
2011-01-26 00:31:30 +08:00
|
|
|
return static_cast<type&&>(
|
2011-01-26 00:14:21 +08:00
|
|
|
static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get());
|
2010-11-18 03:52:17 +08:00
|
|
|
}
|
|
|
|
|
2013-07-13 10:54:05 +08:00
|
|
|
#if _LIBCPP_STD_VER > 11
|
|
|
|
// get by type
|
|
|
|
template <typename _T1, size_t _Idx, typename... _Args>
|
|
|
|
struct __find_exactly_one_t_helper;
|
|
|
|
|
|
|
|
// -- find exactly one
|
|
|
|
template <typename _T1, size_t _Idx, typename... _Args>
|
|
|
|
struct __find_exactly_one_t_checker {
|
|
|
|
static constexpr size_t value = _Idx;
|
|
|
|
// Check the rest of the list to make sure there's only one
|
|
|
|
static_assert ( __find_exactly_one_t_helper<_T1, 0, _Args...>::value == -1, "type can only occur once in type list" );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename _T1, size_t _Idx>
|
|
|
|
struct __find_exactly_one_t_helper <_T1, _Idx> {
|
|
|
|
static constexpr size_t value = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename _T1, size_t _Idx, typename _Head, typename... _Args>
|
|
|
|
struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> {
|
|
|
|
static constexpr size_t value =
|
|
|
|
std::conditional<
|
|
|
|
std::is_same<_T1, _Head>::value,
|
2013-10-01 21:28:20 +08:00
|
|
|
__find_exactly_one_t_checker<_T1, _Idx, _Args...>,
|
2013-07-13 10:54:05 +08:00
|
|
|
__find_exactly_one_t_helper <_T1, _Idx+1, _Args...>
|
|
|
|
>::type::value;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename _T1, typename... _Args>
|
|
|
|
struct __find_exactly_one_t {
|
|
|
|
static constexpr size_t value = __find_exactly_one_t_helper<_T1, 0, _Args...>::value;
|
|
|
|
static_assert ( value != -1, "type not found in type list" );
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _T1, class... _Args>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
constexpr _T1& get(tuple<_Args...>& __tup) noexcept
|
|
|
|
{
|
|
|
|
return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _T1, class... _Args>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
constexpr _T1 const& get(tuple<_Args...> const& __tup) noexcept
|
|
|
|
{
|
|
|
|
return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _T1, class... _Args>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept
|
|
|
|
{
|
2013-07-16 04:46:11 +08:00
|
|
|
return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup));
|
2013-07-13 10:54:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// tie
|
|
|
|
|
|
|
|
template <class ..._Tp>
|
2014-02-26 00:11:46 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple<_Tp&...>
|
2012-07-07 05:53:48 +08:00
|
|
|
tie(_Tp&... __t) _NOEXCEPT
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
return tuple<_Tp&...>(__t...);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Up>
|
|
|
|
struct __ignore_t
|
|
|
|
{
|
|
|
|
template <class _Tp>
|
2010-09-24 02:58:28 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
const __ignore_t& operator=(_Tp&&) const {return *this;}
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
|
|
|
|
|
2013-08-13 02:38:34 +08:00
|
|
|
template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Tp>
|
2014-01-04 06:55:49 +08:00
|
|
|
struct __make_tuple_return_impl
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
typedef _Tp type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Tp>
|
2014-01-04 06:55:49 +08:00
|
|
|
struct __make_tuple_return_impl<reference_wrapper<_Tp> >
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
typedef _Tp& type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Tp>
|
|
|
|
struct __make_tuple_return
|
|
|
|
{
|
2014-01-04 06:55:49 +08:00
|
|
|
typedef typename __make_tuple_return_impl<typename decay<_Tp>::type>::type type;
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class... _Tp>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
tuple<typename __make_tuple_return<_Tp>::type...>
|
|
|
|
make_tuple(_Tp&&... __t)
|
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
return tuple<typename __make_tuple_return<_Tp>::type...>(_VSTD::forward<_Tp>(__t)...);
|
2010-08-20 02:59:38 +08:00
|
|
|
}
|
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
template <class... _Tp>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
|
|
|
tuple<_Tp&&...>
|
2012-07-07 05:53:48 +08:00
|
|
|
forward_as_tuple(_Tp&&... __t) _NOEXCEPT
|
2010-08-20 02:59:38 +08:00
|
|
|
{
|
2011-07-01 05:18:19 +08:00
|
|
|
return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template <size_t _Ip>
|
2010-05-12 03:42:16 +08:00
|
|
|
struct __tuple_equal
|
|
|
|
{
|
|
|
|
template <class _Tp, class _Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const _Tp& __x, const _Up& __y)
|
|
|
|
{
|
2014-06-24 08:46:19 +08:00
|
|
|
return __tuple_equal<_Ip - 1>()(__x, __y) && _VSTD::get<_Ip-1>(__x) == _VSTD::get<_Ip-1>(__y);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct __tuple_equal<0>
|
|
|
|
{
|
|
|
|
template <class _Tp, class _Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const _Tp&, const _Up&)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return !(__x == __y);
|
|
|
|
}
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template <size_t _Ip>
|
2010-05-12 03:42:16 +08:00
|
|
|
struct __tuple_less
|
|
|
|
{
|
|
|
|
template <class _Tp, class _Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const _Tp& __x, const _Up& __y)
|
|
|
|
{
|
2015-01-21 10:51:17 +08:00
|
|
|
const size_t __idx = tuple_size<_Tp>::value - _Ip;
|
|
|
|
if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
|
|
|
|
return true;
|
|
|
|
if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
|
|
|
|
return false;
|
|
|
|
return __tuple_less<_Ip-1>()(__x, __y);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct __tuple_less<0>
|
|
|
|
{
|
|
|
|
template <class _Tp, class _Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool operator()(const _Tp&, const _Up&)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return __tuple_less<sizeof...(_Tp)>()(__x, __y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return __y < __x;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return !(__x < __y);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ..._Tp, class ..._Up>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-05-12 03:42:16 +08:00
|
|
|
bool
|
|
|
|
operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
|
|
|
|
{
|
|
|
|
return !(__y < __x);
|
|
|
|
}
|
|
|
|
|
|
|
|
// tuple_cat
|
|
|
|
|
2010-12-12 04:47:50 +08:00
|
|
|
template <class _Tp, class _Up> struct __tuple_cat_type;
|
|
|
|
|
|
|
|
template <class ..._Ttypes, class ..._Utypes>
|
2011-01-25 00:07:25 +08:00
|
|
|
struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> >
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-12 04:47:50 +08:00
|
|
|
typedef tuple<_Ttypes..., _Utypes...> type;
|
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-12-12 04:47:50 +08:00
|
|
|
template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples>
|
|
|
|
struct __tuple_cat_return_1
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-12 04:47:50 +08:00
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-12-12 04:47:50 +08:00
|
|
|
template <class ..._Types, class _Tuple0>
|
|
|
|
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-12 04:47:50 +08:00
|
|
|
typedef typename __tuple_cat_type<tuple<_Types...>,
|
|
|
|
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
|
|
|
|
type;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples>
|
|
|
|
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples...>
|
|
|
|
: public __tuple_cat_return_1<
|
|
|
|
typename __tuple_cat_type<
|
|
|
|
tuple<_Types...>,
|
|
|
|
typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
|
|
|
|
>::type,
|
|
|
|
__tuple_like<typename remove_reference<_Tuple1>::type>::value,
|
|
|
|
_Tuple1, _Tuples...>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class ..._Tuples> struct __tuple_cat_return;
|
|
|
|
|
|
|
|
template <class _Tuple0, class ..._Tuples>
|
|
|
|
struct __tuple_cat_return<_Tuple0, _Tuples...>
|
|
|
|
: public __tuple_cat_return_1<tuple<>,
|
|
|
|
__tuple_like<typename remove_reference<_Tuple0>::type>::value, _Tuple0,
|
|
|
|
_Tuples...>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct __tuple_cat_return<>
|
|
|
|
{
|
|
|
|
typedef tuple<> type;
|
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-12-12 04:47:50 +08:00
|
|
|
tuple<>
|
|
|
|
tuple_cat()
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-12 04:47:50 +08:00
|
|
|
return tuple<>();
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template <class _Rp, class _Indices, class _Tuple0, class ..._Tuples>
|
2010-12-13 07:04:37 +08:00
|
|
|
struct __tuple_cat_return_ref_imp;
|
|
|
|
|
|
|
|
template <class ..._Types, size_t ..._I0, class _Tuple0>
|
|
|
|
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0>
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-13 07:04:37 +08:00
|
|
|
typedef typename remove_reference<_Tuple0>::type _T0;
|
|
|
|
typedef tuple<_Types..., typename __apply_cv<_Tuple0,
|
|
|
|
typename tuple_element<_I0, _T0>::type>::type&&...> type;
|
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-12-13 07:04:37 +08:00
|
|
|
template <class ..._Types, size_t ..._I0, class _Tuple0, class _Tuple1, class ..._Tuples>
|
|
|
|
struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>,
|
|
|
|
_Tuple0, _Tuple1, _Tuples...>
|
|
|
|
: public __tuple_cat_return_ref_imp<
|
|
|
|
tuple<_Types..., typename __apply_cv<_Tuple0,
|
|
|
|
typename tuple_element<_I0,
|
|
|
|
typename remove_reference<_Tuple0>::type>::type>::type&&...>,
|
|
|
|
typename __make_tuple_indices<tuple_size<typename
|
|
|
|
remove_reference<_Tuple1>::type>::value>::type,
|
|
|
|
_Tuple1, _Tuples...>
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-13 07:04:37 +08:00
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-12-13 07:04:37 +08:00
|
|
|
template <class _Tuple0, class ..._Tuples>
|
|
|
|
struct __tuple_cat_return_ref
|
|
|
|
: public __tuple_cat_return_ref_imp<tuple<>,
|
|
|
|
typename __make_tuple_indices<
|
|
|
|
tuple_size<typename remove_reference<_Tuple0>::type>::value
|
|
|
|
>::type, _Tuple0, _Tuples...>
|
2010-12-12 04:47:50 +08:00
|
|
|
{
|
2010-12-13 07:04:37 +08:00
|
|
|
};
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2010-12-13 07:04:37 +08:00
|
|
|
template <class _Types, class _I0, class _J0>
|
|
|
|
struct __tuple_cat;
|
|
|
|
|
|
|
|
template <class ..._Types, size_t ..._I0, size_t ..._J0>
|
2011-01-25 00:07:25 +08:00
|
|
|
struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> >
|
2010-12-13 07:04:37 +08:00
|
|
|
{
|
|
|
|
template <class _Tuple0>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-12-13 07:04:37 +08:00
|
|
|
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
|
|
|
|
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
|
|
|
|
{
|
2014-06-24 08:46:19 +08:00
|
|
|
return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
|
|
|
|
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
|
2010-12-13 07:04:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _Tuple0, class _Tuple1, class ..._Tuples>
|
2013-07-23 00:02:19 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-12-13 07:04:37 +08:00
|
|
|
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
|
|
|
|
operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls)
|
|
|
|
{
|
|
|
|
typedef typename remove_reference<_Tuple0>::type _T0;
|
|
|
|
typedef typename remove_reference<_Tuple1>::type _T1;
|
|
|
|
return __tuple_cat<
|
|
|
|
tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
|
|
|
|
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
|
|
|
|
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
|
2013-10-06 02:46:37 +08:00
|
|
|
(forward_as_tuple(
|
2014-06-24 08:46:19 +08:00
|
|
|
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
|
|
|
|
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
|
2010-12-13 07:04:37 +08:00
|
|
|
),
|
2011-07-01 05:18:19 +08:00
|
|
|
_VSTD::forward<_Tuple1>(__t1),
|
|
|
|
_VSTD::forward<_Tuples>(__tpls)...);
|
2010-12-13 07:04:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Tuple0, class... _Tuples>
|
2013-07-23 00:02:19 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
2010-12-13 07:04:37 +08:00
|
|
|
typename __tuple_cat_return<_Tuple0, _Tuples...>::type
|
|
|
|
tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
2010-12-13 07:04:37 +08:00
|
|
|
typedef typename remove_reference<_Tuple0>::type _T0;
|
|
|
|
return __tuple_cat<tuple<>, __tuple_indices<>,
|
|
|
|
typename __make_tuple_indices<tuple_size<_T0>::value>::type>()
|
2011-07-01 05:18:19 +08:00
|
|
|
(tuple<>(), _VSTD::forward<_Tuple0>(__t0),
|
|
|
|
_VSTD::forward<_Tuples>(__tpls)...);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class ..._Tp, class _Alloc>
|
2013-08-13 02:38:34 +08:00
|
|
|
struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc>
|
2010-05-12 03:42:16 +08:00
|
|
|
: true_type {};
|
|
|
|
|
|
|
|
template <class _T1, class _T2>
|
|
|
|
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
pair<_T1, _T2>::pair(piecewise_construct_t,
|
|
|
|
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
|
|
|
|
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
|
2014-06-24 08:46:19 +08:00
|
|
|
: first(_VSTD::forward<_Args1>(_VSTD::get<_I1>( __first_args))...),
|
|
|
|
second(_VSTD::forward<_Args2>(_VSTD::get<_I2>(__second_args))...)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_HAS_NO_VARIADICS
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
|
|
|
#endif // _LIBCPP_TUPLE
|