diff options
author | Louis Dionne <ldionne@apple.com> | 2019-08-12 18:30:31 +0000 |
---|---|---|
committer | Louis Dionne <ldionne@apple.com> | 2019-08-12 18:30:31 +0000 |
commit | 1308011e1b5c5382281a63dd4191a1784f8d2295 (patch) | |
tree | 1fbf40bca77bc711b1055f6195ff6bf99277d18e /libcxx/include | |
parent | 38a1aa117f3d1974ab6653b692e9946e3d11db4a (diff) | |
download | bcm5719-llvm-1308011e1b5c5382281a63dd4191a1784f8d2295.tar.gz bcm5719-llvm-1308011e1b5c5382281a63dd4191a1784f8d2295.zip |
[libc++] Implement CTAD for std::tuple
Summary:
We were using implicit deduction guides instead of explicit ones,
however the implicit ones don't do work anymore when changing the
constructors.
This commit adds the actual guides specified in the Standard to make
libc++ (1) closer to the Standard and (2) more resistent to changes
in std::tuple's constructors.
Reviewers: Quuxplusone
Subscribers: christof, jkorous, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D65225
llvm-svn: 368599
Diffstat (limited to 'libcxx/include')
-rw-r--r-- | libcxx/include/tuple | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/libcxx/include/tuple b/libcxx/include/tuple index 65065872991..32bc86913aa 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -69,6 +69,17 @@ public: void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); }; +template <class ...T> +tuple(T...) -> tuple<T...>; // since C++17 +template <class T1, class T2> +tuple(pair<T1, T2>) -> tuple<T1, T2>; // since C++17 +template <class Alloc, class ...T> +tuple(allocator_arg_t, Alloc, T...) -> tuple<T...>; // since C++17 +template <class Alloc, class T1, class T2> +tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++17 +template <class Alloc, class ...T> +tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17 + inline constexpr unspecified ignore; template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 @@ -943,13 +954,16 @@ public: }; #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES -// NOTE: These are not yet standardized, but are required to simulate the -// implicit deduction guide that should be generated had libc++ declared the -// tuple-like constructors "correctly" -template <class _Alloc, class ..._Args> -tuple(allocator_arg_t, const _Alloc&, tuple<_Args...> const&) -> tuple<_Args...>; -template <class _Alloc, class ..._Args> -tuple(allocator_arg_t, const _Alloc&, tuple<_Args...>&&) -> tuple<_Args...>; +template <class ..._Tp> +tuple(_Tp...) -> tuple<_Tp...>; +template <class _Tp1, class _Tp2> +tuple(pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>; +template <class _Alloc, class ..._Tp> +tuple(allocator_arg_t, _Alloc, _Tp...) -> tuple<_Tp...>; +template <class _Alloc, class _Tp1, class _Tp2> +tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>; +template <class _Alloc, class ..._Tp> +tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; #endif template <class ..._Tp> |