- template<std::size_t _Idx, typename _Head, typename... _Tail>
- struct _Tuple_impl<_Idx, _Head, _Tail...>
- : public _Tuple_impl<_Idx + 1, _Tail...>,
- private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value>
- {
- template<std::size_t, typename...> friend class _Tuple_impl;
- typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
- typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base;
- static constexpr _Head&
- _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
- static constexpr const _Head&
- _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
- static constexpr _Inherited&
- _M_tail(_Tuple_impl& __t) noexcept { return __t; }
- static constexpr const _Inherited&
- _M_tail(const _Tuple_impl& __t) noexcept { return __t; }
- constexpr _Tuple_impl()
- : _Inherited(), _Base() { }
- explicit
- constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail)
- : _Inherited(__tail...), _Base(__head) { }
- template<typename _UHead, typename... _UTail, typename = typename
- enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type>
- explicit
- constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
- : _Inherited(std::forward<_UTail>(__tail)...),
- _Base(std::forward<_UHead>(__head)) { }
- constexpr _Tuple_impl(const _Tuple_impl&) = default;
- constexpr
- _Tuple_impl(_Tuple_impl&& __in)
- noexcept(__and_<is_nothrow_move_constructible<_Head>,
- is_nothrow_move_constructible<_Inherited>>::value)
- : _Inherited(std::move(_M_tail(__in))),
- _Base(std::forward<_Head>(_M_head(__in))) { }
- template<typename... _UElements>
- constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
- : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
- _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
- template<typename _UHead, typename... _UTails>
- constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
- : _Inherited(std::move
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
- _Base(std::forward<_UHead>
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
- template<typename _Alloc>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
- : _Inherited(__tag, __a),
- _Base(__use_alloc<_Head>(__a)) { }
- template<typename _Alloc>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- const _Head& __head, const _Tail&... __tail)
- : _Inherited(__tag, __a, __tail...),
- _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
- template<typename _Alloc, typename _UHead, typename... _UTail,
- typename = typename enable_if<sizeof...(_Tail)
- == sizeof...(_UTail)>::type>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- _UHead&& __head, _UTail&&... __tail)
- : _Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
- _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
- std::forward<_UHead>(__head)) { }
- template<typename _Alloc>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- const _Tuple_impl& __in)
- : _Inherited(__tag, __a, _M_tail(__in)),
- _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
- template<typename _Alloc>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- _Tuple_impl&& __in)
- : _Inherited(__tag, __a, std::move(_M_tail(__in))),
- _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
- std::forward<_Head>(_M_head(__in))) { }
- template<typename _Alloc, typename... _UElements>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- const _Tuple_impl<_Idx, _UElements...>& __in)
- : _Inherited(__tag, __a,
- _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
- _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
- _Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
- template<typename _Alloc, typename _UHead, typename... _UTails>
- _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
- _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
- : _Inherited(__tag, __a, std::move
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
- _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
- std::forward<_UHead>
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
- _Tuple_impl&
- operator=(const _Tuple_impl& __in)
- {
- _M_head(*this) = _M_head(__in);
- _M_tail(*this) = _M_tail(__in);
- return *this;
- }
- _Tuple_impl&
- operator=(_Tuple_impl&& __in)
- noexcept(__and_<is_nothrow_move_assignable<_Head>,
- is_nothrow_move_assignable<_Inherited>>::value)
- {
- _M_head(*this) = std::forward<_Head>(_M_head(__in));
- _M_tail(*this) = std::move(_M_tail(__in));
- return *this;
- }
- template<typename... _UElements>
- _Tuple_impl&
- operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
- {
- _M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in);
- _M_tail(*this) = _Tuple_impl<_Idx, _UElements...>::_M_tail(__in);
- return *this;
- }
- template<typename _UHead, typename... _UTails>
- _Tuple_impl&
- operator=(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
- {
- _M_head(*this) = std::forward<_UHead>
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in));
- _M_tail(*this) = std::move
- (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in));
- return *this;
- }
- protected:
- void
- _M_swap(_Tuple_impl& __in)
- noexcept(noexcept(swap(std::declval<_Head&>(),
- std::declval<_Head&>()))
- && noexcept(_M_tail(__in)._M_swap(_M_tail(__in))))
- {
- using std::swap;
- swap(_M_head(*this), _M_head(__in));
- _Inherited::_M_swap(_M_tail(__in));
- }
- };