diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2012-04-01 23:10:42 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2012-04-01 23:10:42 +0000 |
| commit | 0527c6207af5de565bbd77e64f953bbc785cee8d (patch) | |
| tree | 2d0a9a080fe505fe562b4072bd60993b22fd6ff9 /libcxx/include/__tuple | |
| parent | 0090df24d75ddd9ab2d4b913cf74d613b09a2335 (diff) | |
| download | bcm5719-llvm-0527c6207af5de565bbd77e64f953bbc785cee8d.tar.gz bcm5719-llvm-0527c6207af5de565bbd77e64f953bbc785cee8d.zip | |
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.
llvm-svn: 153855
Diffstat (limited to 'libcxx/include/__tuple')
| -rw-r--r-- | libcxx/include/__tuple | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/libcxx/include/__tuple b/libcxx/include/__tuple index 3b2be1c5a74..82168048e6c 100644 --- a/libcxx/include/__tuple +++ b/libcxx/include/__tuple @@ -216,7 +216,7 @@ struct __tuple_convertible_imp : public false_type {}; template <class _Tp0, class ..._Tp, class _Up0, class ..._Up> struct __tuple_convertible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> > : public integral_constant<bool, - is_constructible<_Up0, _Tp0>::value && + is_convertible<_Tp0, _Up0>::value && __tuple_convertible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {}; template <> @@ -235,6 +235,33 @@ struct __tuple_convertible<_Tp, _Up, true, true> typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> {}; +// __tuple_constructible + +template <bool, class _Tp, class _Up> +struct __tuple_constructible_imp : public false_type {}; + +template <class _Tp0, class ..._Tp, class _Up0, class ..._Up> +struct __tuple_constructible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...> > + : public integral_constant<bool, + is_constructible<_Up0, _Tp0>::value && + __tuple_constructible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...> >::value> {}; + +template <> +struct __tuple_constructible_imp<true, __tuple_types<>, __tuple_types<> > + : public true_type {}; + +template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value, + bool = __tuple_like<_Up>::value> +struct __tuple_constructible + : public false_type {}; + +template <class _Tp, class _Up> +struct __tuple_constructible<_Tp, _Up, true, true> + : public __tuple_constructible_imp<tuple_size<typename remove_reference<_Tp>::type>::value == + tuple_size<_Up>::value, + typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type> +{}; + // __tuple_assignable template <bool, class _Tp, class _Up> |

