[pushed] libstdc++: Add P1206R7 from_range members to container adaptors [PR111055]

Jonathan Wakely jwakely@redhat.com
Fri Mar 14 11:31:02 GMT 2025


On 13/03/25 16:41 +0100, tkaminsk@redhat.com wrote:
>From: Tomasz Kamiński <tkaminsk@redhat.com>
>
>This is another piece of P1206R7, adding new members to std::stack,
>std::queue, and std::priority_queue.
>
>	PR libstdc++/111055
>
>libstdc++-v3/ChangeLog:
>
>	* include/bits/stl_queue.h (queue(from_range_t, _Rg&&))
>	(queue(from_range_t, _Rg&&, const _Alloc&), push_range):
>	Define.
>	(priority_queue(from_range_t, R&&, const Compare&))
>	(push_range): Define.
>	* include/bits/stl_stack.h (stack(from_range_t, R&&))
>	(stack(from_range_t, R&&, const Alloc&), push_range): Define.
>	* testsuite/util/testsuite_iterators.h (test_range_nocopy): Define.
>	* testsuite/23_containers/priority_queue/cons_from_range.cc: New test.
>	* testsuite/23_containers/priority_queue/members/push_range.cc: New test.
>	* testsuite/23_containers/queue/cons_from_range.cc: New test.
>	* testsuite/23_containers/queue/members/push_range.cc: New test.
>	* testsuite/23_containers/stack/cons_from_range.cc: New test.
>	* testsuite/23_containers/stack/members/push_range.cc: New test.
>---
>Pushed to trunk.
>Approved by Jonathan Wakely on sourceforge:
>https://forge.sourceware.org/gcc/gcc-TEST/pulls/43#issuecomment-780.
>
> libstdc++-v3/include/bits/stl_queue.h         | 102 ++++++++++++++++
> libstdc++-v3/include/bits/stl_stack.h         |  46 ++++++++
> .../priority_queue/cons_from_range.cc         | 111 ++++++++++++++++++
> .../priority_queue/members/push_range.cc      |  86 ++++++++++++++
> .../23_containers/queue/cons_from_range.cc    |  88 ++++++++++++++
> .../23_containers/queue/members/push_range.cc |  73 ++++++++++++
> .../23_containers/stack/cons_from_range.cc    |  89 ++++++++++++++
> .../23_containers/stack/members/push_range.cc |  74 ++++++++++++
> .../testsuite/util/testsuite_iterators.h      |  11 ++
> 9 files changed, 680 insertions(+)
> create mode 100644 libstdc++-v3/testsuite/23_containers/priority_queue/cons_from_range.cc
> create mode 100644 libstdc++-v3/testsuite/23_containers/priority_queue/members/push_range.cc
> create mode 100644 libstdc++-v3/testsuite/23_containers/queue/cons_from_range.cc
> create mode 100644 libstdc++-v3/testsuite/23_containers/queue/members/push_range.cc
> create mode 100644 libstdc++-v3/testsuite/23_containers/stack/cons_from_range.cc
> create mode 100644 libstdc++-v3/testsuite/23_containers/stack/members/push_range.cc
>



>diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/cons_from_range.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/cons_from_range.cc
>new file mode 100644
>index 00000000000..a7ff3e3b037
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/cons_from_range.cc
>@@ -0,0 +1,111 @@
>+// { dg-do run { target c++23 } }
>+
>+#include <queue>
>+#include <ranges>
>+#include <span>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+#include <testsuite_iterators.h>
>+#include <vector>

THe ARM CI fails for this test, because #include <algorithm> is
missing.

You won't see this with a default config because
--enable-libstdcxx-pch is enabled by default, and that means every
test gets run with -include bits/stdc++.h which includes the entire
library as a precompiled header.

For a PCH-disabled build, the tests fail if they don't include the
right headers.

(I get around this problem by doing my local testing on a build
without PCH, then run the full testsuite in the compile farm or on
other many-core servers with PCH enabled.)

>diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/members/push_range.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/members/push_range.cc
>new file mode 100644
>index 00000000000..a380dbd1098
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/members/push_range.cc
>@@ -0,0 +1,86 @@
>+// { dg-do run { target c++23 } }
>+
>+#include <queue>
>+#include <ranges>
>+#include <span>
>+#include <testsuite_allocator.h>
>+#include <testsuite_hooks.h>
>+#include <testsuite_iterators.h>
>+#include <vector>

This needs #include <algorithm> too.

A patch to add that header to these two tests is pre-approved.



More information about the Libstdc++ mailing list