diff --git a/include/__tuple/sfinae_helpers.h b/include/__tuple/sfinae_helpers.h index 35a57ff..dfd00f5 100644 --- a/include/__tuple/sfinae_helpers.h +++ b/include/__tuple/sfinae_helpers.h @@ -41,7 +41,7 @@ struct __tuple_sfinae_base { static auto __do_test(...) -> false_type; template - using __constructible = decltype(__do_test(_ToArgs{}, _FromArgs{})); + using __constructible = decltype(__do_test(declval<_ToArgs>(), declval<_FromArgs>())); }; // __tuple_constructible @@ -49,11 +49,17 @@ struct __tuple_sfinae_base { template >::value, - bool = __tuple_like_ext<_Up>::value> + bool = __tuple_like_ext<_Up>::value, + class = void> struct __tuple_constructible : public false_type {}; template -struct __tuple_constructible<_Tp, _Up, true, true> +struct __tuple_constructible< + _Tp, + _Up, + true, + true, + typename enable_if<(tuple_size::type>::value == tuple_size<_Up>::value)>::type> : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type > {}; diff --git a/include/__tuple/tuple_element.h b/include/__tuple/tuple_element.h index 55b3b47..c6818f2 100644 --- a/include/__tuple/tuple_element.h +++ b/include/__tuple/tuple_element.h @@ -60,11 +60,26 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); } // namespace __indexer_detail +# if !defined(__CUDACC__) || !defined(_MSC_VER) template using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>( __indexer_detail::__indexer< __tuple_types<_Types...>, typename __make_tuple_indices::type >{}))::type; -# endif +# else // !defined(__CUDACC__) || !defined(_MSC_VER) +template +struct __y_type_pack_element { + using __t1 = typename __make_tuple_indices::type; + using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>; + using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{})); + using __t4 = typename __t3::type; +}; + +template +using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4; + +# endif // !defined(__CUDACC__) || !defined(_MSC_VER) + +# endif // __has_builtin(__type_pack_element) template struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {