]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix std::stack deduction guide
authorJonathan Wakely <jwakely@redhat.com>
Tue, 19 Oct 2021 10:38:26 +0000 (11:38 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 19 Oct 2021 14:01:16 +0000 (15:01 +0100)
libstdc++-v3/ChangeLog:

* include/bits/stl_stack.h (stack(Iterator, Iterator)): Remove
non-deducible template parameter from deduction guide.
* testsuite/23_containers/stack/deduction.cc: Check new C++23
deduction guides.

libstdc++-v3/include/bits/stl_stack.h
libstdc++-v3/testsuite/23_containers/stack/deduction.cc

index 429743f5514ced29b266944f44abd3c5ad5bf71c..76b2e242c37f02734defddd87cca9c5c749f8c6c 100644 (file)
@@ -322,7 +322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     -> stack<typename _Container::value_type, _Container>;
 
 #ifdef __cpp_lib_adaptor_iterator_pair_constructor
-  template<typename _InputIterator, typename _Allocator,
+  template<typename _InputIterator,
           typename _ValT
             = typename iterator_traits<_InputIterator>::value_type,
           typename = _RequireInputIter<_InputIterator>>
index 169a063687b5bd8dc424e1d7c2d14e5ce90d12be..dea7ba060d92cdcfe9b23069b1a7a97ca33f7b98 100644 (file)
@@ -87,3 +87,17 @@ test02()
   std::stack s8(std::move(l), l.get_allocator());
   check_type<std::stack<long, std::list<long>>>(s8);
 }
+
+#if __cpp_lib_adaptor_iterator_pair_constructor
+void
+test03()
+{
+  std::list<long> l;
+
+  std::stack s1(l.begin(), l.end());
+  check_type<std::stack<long>>(s1);
+
+  std::stack s2(l.begin(), l.end(), std::allocator<long>());
+  check_type<std::stack<long>>(s1);
+}
+#endif