25__tuple.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. diff --git a/include/__tuple/sfinae_helpers.h b/include/__tuple/sfinae_helpers.h
  2. index 35a57ff..dfd00f5 100644
  3. --- a/include/__tuple/sfinae_helpers.h
  4. +++ b/include/__tuple/sfinae_helpers.h
  5. @@ -41,7 +41,7 @@ struct __tuple_sfinae_base {
  6. static auto __do_test(...) -> false_type;
  7. template <class _FromArgs, class _ToArgs>
  8. - using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
  9. + using __constructible = decltype(__do_test<is_constructible>(declval<_ToArgs>(), declval<_FromArgs>()));
  10. };
  11. // __tuple_constructible
  12. @@ -49,11 +49,17 @@ struct __tuple_sfinae_base {
  13. template <class _Tp,
  14. class _Up,
  15. bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
  16. - bool = __tuple_like_ext<_Up>::value>
  17. + bool = __tuple_like_ext<_Up>::value,
  18. + class = void>
  19. struct __tuple_constructible : public false_type {};
  20. template <class _Tp, class _Up>
  21. -struct __tuple_constructible<_Tp, _Up, true, true>
  22. +struct __tuple_constructible<
  23. + _Tp,
  24. + _Up,
  25. + true,
  26. + true,
  27. + typename enable_if<(tuple_size<typename remove_reference<_Tp>::type>::value == tuple_size<_Up>::value)>::type>
  28. : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type,
  29. typename __make_tuple_types<_Up>::type > {};
  30. diff --git a/include/__tuple/tuple_element.h b/include/__tuple/tuple_element.h
  31. index 55b3b47..c6818f2 100644
  32. --- a/include/__tuple/tuple_element.h
  33. +++ b/include/__tuple/tuple_element.h
  34. @@ -60,11 +60,26 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
  35. } // namespace __indexer_detail
  36. +# if !defined(__CUDACC__) || !defined(_MSC_VER)
  37. template <size_t _Idx, class... _Types>
  38. using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>(
  39. __indexer_detail::__indexer< __tuple_types<_Types...>,
  40. typename __make_tuple_indices<sizeof...(_Types)>::type >{}))::type;
  41. -# endif
  42. +# else // !defined(__CUDACC__) || !defined(_MSC_VER)
  43. +template <size_t _Idx, class... _Types>
  44. +struct __y_type_pack_element {
  45. + using __t1 = typename __make_tuple_indices<sizeof...(_Types)>::type;
  46. + using __t2 = __indexer_detail::__indexer<__tuple_types<_Types...>, __t1>;
  47. + using __t3 = decltype(__indexer_detail::__at_index<_Idx>(__t2{}));
  48. + using __t4 = typename __t3::type;
  49. +};
  50. +
  51. +template <size_t _Idx, class... _Types>
  52. +using __type_pack_element = typename __y_type_pack_element<_Idx, _Types...>::__t4;
  53. +
  54. +# endif // !defined(__CUDACC__) || !defined(_MSC_VER)
  55. +
  56. +# endif // __has_builtin(__type_pack_element)
  57. template <size_t _Ip, class... _Types>
  58. struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {