aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-03-01 11:16:58 +0000
committerJonathan Wakely <jwakely@redhat.com>2024-05-02 10:07:38 +0100
commit0ecb0967b4f7e68027492ac03e5dc03b5bcfdcf7 (patch)
tree9502e4f4ba51391d054a21cc003ee82f88ed8260
parentf82e31be9404c008b64cd351ccb93604d9530ecb (diff)
downloadgcc-upstream-releases/gcc-11.tar.gz
libstdc++: Add missing std::tuple constructor [PR114147]releases/gcc-11
I caused a regression with commit r10-908 by adding a constraint to the non-explicit allocator-extended default constructor, but seemingly forgot to add an explicit overload with the corresponding constraint. libstdc++-v3/ChangeLog: PR libstdc++/114147 * include/std/tuple (tuple::tuple(allocator_arg_t, const Alloc&)): Add missing overload of allocator-extended default constructor. (tuple<T1,T2>::tuple(allocator_arg_t, const Alloc&)): Likewise. * testsuite/20_util/tuple/cons/114147.cc: New test. (cherry picked from commit 0a545ac7000501844670add0b3560ebdbcb123c6)
-rw-r--r--libstdc++-v3/include/std/tuple14
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc15
2 files changed, 29 insertions, 0 deletions
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 63bd68fbe43..b02b0bfbd59 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -801,6 +801,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
+ template<typename _Alloc,
+ _ExplicitDefaultCtor<is_object<_Alloc>::value> = false>
+ _GLIBCXX20_CONSTEXPR
+ explicit
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1),
_ImplicitCtor<_NotEmpty, const _Elements&...> = true>
_GLIBCXX20_CONSTEXPR
@@ -1155,6 +1162,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
+ template<typename _Alloc,
+ _ExplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = false>
+ _GLIBCXX20_CONSTEXPR
+ explicit
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
template<typename _Alloc, bool _Dummy = true,
_ImplicitCtor<_Dummy, const _T1&, const _T2&> = true>
_GLIBCXX20_CONSTEXPR
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
new file mode 100644
index 00000000000..916e7204964
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+
+// PR libstdc++/114147
+// tuple allocator-extended ctor requires non-explicit default ctor
+
+#include <tuple>
+#include <memory>
+
+struct X { explicit X(); };
+
+std::allocator<int> a;
+std::tuple<X> t0(std::allocator_arg, a);
+std::tuple<int, X> t1(std::allocator_arg, a);
+std::tuple<X, int> t2(std::allocator_arg, a);
+std::tuple<int, X, int> t3(std::allocator_arg, a);