I believe tuple is still under development in the standard. Daniel Krugler is/will be making convincing arguments that a modified form of LWG 2051 (currently NAD Future) is easily acheivable and desirable. He has demonstrated that a tuple<T...> where all of the T are implicitly convertible from U... should have a tuple constructor that is also implicit, instead of explicit. This would support the use cases in LWG 2051 while not undermining T... with explicit conversions from U.... This check-in is an experimental implementation of Daniel's work. I believe this work to be mature enough to warrant inclusion into libc++. If anyone sees real-world problems that this check in causes, please let me know and I will revert it, and provide the feedback to the LWG.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@153855 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/tuple b/include/tuple
index 2bdb05f..683c9dd 100644
--- a/include/tuple
+++ b/include/tuple
@@ -552,7 +552,7 @@
) {}
template <class ..._Up,
- class = typename enable_if
+ typename enable_if
<
sizeof...(_Up) <= sizeof...(_Tp) &&
__tuple_convertible
@@ -562,8 +562,40 @@
sizeof...(_Up) < sizeof...(_Tp) ?
sizeof...(_Up) :
sizeof...(_Tp)>::type
- >::value
- >::type
+ >::value,
+ bool
+ >::type = false
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ tuple(_Up&&... __u)
+ : 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
+ >::value,
+ bool
+ >::type =false
>
_LIBCPP_INLINE_VISIBILITY
explicit
@@ -598,15 +630,29 @@
_VSTD::forward<_Up>(__u)...) {}
template <class _Tuple,
- class = typename enable_if
+ typename enable_if
<
- __tuple_convertible<_Tuple, tuple>::value
- >::type
+ __tuple_convertible<_Tuple, tuple>::value,
+ bool
+ >::type = false
>
_LIBCPP_INLINE_VISIBILITY
tuple(_Tuple&& __t)
: base_(_VSTD::forward<_Tuple>(__t)) {}
+ template <class _Tuple,
+ typename enable_if
+ <
+ __tuple_constructible<_Tuple, tuple>::value &&
+ !__tuple_convertible<_Tuple, tuple>::value,
+ bool
+ >::type = false
+ >
+ _LIBCPP_INLINE_VISIBILITY
+ explicit
+ tuple(_Tuple&& __t)
+ : base_(_VSTD::forward<_Tuple>(__t)) {}
+
template <class _Alloc, class _Tuple,
class = typename enable_if
<