[libcxx-commits] [PATCH] D65225: [libc++] Implement CTAD for std::tuple

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 24 10:21:28 PDT 2019


ldionne created this revision.
ldionne added reviewers: EricWF, Quuxplusone.
Herald added subscribers: libcxx-commits, dexonsmith, jkorous, christof.
Herald added a project: libc++.

Apparently all the tests were already there, but the actual deduction
guides weren't in place. The implicitly CTAD does the job given the
current set of constructors, however changing the constructors can
break that.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65225

Files:
  libcxx/include/tuple


Index: libcxx/include/tuple
===================================================================
--- libcxx/include/tuple
+++ libcxx/include/tuple
@@ -943,13 +943,16 @@
 };
 
 #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>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65225.211549.patch
Type: text/x-patch
Size: 1148 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190724/a51344a4/attachment.bin>


More information about the libcxx-commits mailing list