diff --git a/include/utility b/include/utility index f4a86b64..ba656493 100644 --- a/include/utility +++ b/include/utility @@ -602,7 +602,7 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT #if _LIBCPP_STD_VER > 11 template -struct integer_sequence +struct _LIBCPP_TYPE_VIS integer_sequence { typedef _Tp value_type; static_assert( is_integral<_Tp>::value, @@ -617,26 +617,53 @@ struct integer_sequence template using index_sequence = integer_sequence; -template -struct __make_integer_sequence_unchecked; +namespace __detail { -template -struct __make_integer_sequence_unchecked<_Tp, _Sp, _Ep, - integer_sequence<_Tp, _Indices...>> -{ - typedef typename __make_integer_sequence_unchecked - < - _Tp, _Sp+1, _Ep, - integer_sequence<_Tp, _Indices..., _Sp> - >::type type; +template struct __repeat; +template struct __repeat, _Extra...> { + typedef integer_sequence<_Tp, + _Np..., + sizeof...(_Np) + _Np..., + 2 * sizeof...(_Np) + _Np..., + 3 * sizeof...(_Np) + _Np..., + 4 * sizeof...(_Np) + _Np..., + 5 * sizeof...(_Np) + _Np..., + 6 * sizeof...(_Np) + _Np..., + 7 * sizeof...(_Np) + _Np..., + _Extra...> type; }; -template -struct __make_integer_sequence_unchecked<_Tp, _Ep, _Ep, - integer_sequence<_Tp, _Indices...>> -{ - typedef integer_sequence<_Tp, _Indices...> type; +template struct __parity; +template struct __make : __parity<_Np % 8>::template __pmake<_Np> {}; + +template<> struct __make<0> { typedef integer_sequence type; }; +template<> struct __make<1> { typedef integer_sequence type; }; +template<> struct __make<2> { typedef integer_sequence type; }; +template<> struct __make<3> { typedef integer_sequence type; }; +template<> struct __make<4> { typedef integer_sequence type; }; +template<> struct __make<5> { typedef integer_sequence type; }; +template<> struct __make<6> { typedef integer_sequence type; }; +template<> struct __make<7> { typedef integer_sequence type; }; + +template<> struct __parity<0> { template struct __pmake : __repeat::type> {}; }; +template<> struct __parity<1> { template struct __pmake : __repeat::type, _Np - 1> {}; }; +template<> struct __parity<2> { template struct __pmake : __repeat::type, _Np - 2, _Np - 1> {}; }; +template<> struct __parity<3> { template struct __pmake : __repeat::type, _Np - 3, _Np - 2, _Np - 1> {}; }; +template<> struct __parity<4> { template struct __pmake : __repeat::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; +template<> struct __parity<5> { template struct __pmake : __repeat::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; +template<> struct __parity<6> { template struct __pmake : __repeat::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; +template<> struct __parity<7> { template struct __pmake : __repeat::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; }; + +template struct __convert { + template struct __result; + template<_Tp ..._Np> struct __result > { typedef integer_sequence<_Up, _Np...> type; }; }; +template struct __convert<_Tp, _Tp> { template struct __result { typedef _Up type; }; }; + +} + +template using __make_integer_sequence_unchecked = + typename __detail::__convert::template __result::type>::type; template struct __make_integer_sequence @@ -644,10 +671,7 @@ struct __make_integer_sequence static_assert(is_integral<_Tp>::value, "std::make_integer_sequence can only be instantiated with an integral type" ); static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative"); - typedef typename __make_integer_sequence_unchecked - < - _Tp, 0, _Ep, integer_sequence<_Tp> - >::type type; + typedef __make_integer_sequence_unchecked<_Tp, _Ep> type; }; template