]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Include range_access.h from <valarray>
authorTomasz Kamiński <tkaminsk@redhat.com>
Thu, 14 May 2026 12:47:03 +0000 (14:47 +0200)
committerTomasz Kamiński <tkaminsk@redhat.com>
Mon, 18 May 2026 15:40:19 +0000 (17:40 +0200)
This implements <valarray> related parts of section 4.8. of P3016R6.
This is treated as DR against C++11 (to expose array begin/end), to follow
similar changes to other semi-containers that were accepted as LWG issues
and treated as DR: <optional> (LWG4131), <stacktrace> (LWG3625).

libstdc++-v3/ChangeLog:

* include/std/valarray [__cplusplus >= 201103L]: Include
<bits/ranges_access.h>.
* testsuite/26_numerics/valarray/range_access2.cc: Remove
<iterator> include, and add test for std::size.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/std/valarray
libstdc++-v3/testsuite/26_numerics/valarray/range_access2.cc

index 63784fb5974ae49ae809640a2c16c4b4c7d42c46..abb158d22c35672e0ba045de18827cafef119cf4 100644 (file)
@@ -43,6 +43,7 @@
 #include <debug/debug.h>
 #if __cplusplus >= 201103L
 #include <initializer_list>
+#include <bits/range_access.h>
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
index 8a4f2b659e5affe56651d24b2da08292a76c6a16..44ea7fc4b60190e767fd6086d9a85a0e8a740a21 100644 (file)
@@ -19,7 +19,6 @@
 
 // C++11 26.6.10 valarray range access: [valarray.range]
 
-#include <iterator>
 #include <valarray>
 
 // PR libstdc++/67374
@@ -46,8 +45,21 @@ test02()
   (void) std::cend(cva);
 }
 
+// P3016R6 4.8
+void
+test03()
+{
+#if __cplusplus >= 201703L
+  std::valarray<double> va;
+  (void) std::size(va);
+  const auto& cva = va;
+  (void) std::size(cva);
+#endif
+}
+
 int main()
 {
   test01();
   test02();
+  test03();
 }