aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-11-09 15:15:08 -0500
committerPatrick Palka <ppalka@redhat.com>2023-11-09 15:15:08 -0500
commitd63282fa5b587f1b994210212f236b998a332995 (patch)
tree5c291893ef03e864697b68b34fccb61da5fe10e3 /libstdc++-v3/testsuite/std
parent6c2ac6e9ce152e120f166866c5c77924c726db99 (diff)
downloadgcc-d63282fa5b587f1b994210212f236b998a332995.zip
gcc-d63282fa5b587f1b994210212f236b998a332995.tar.gz
gcc-d63282fa5b587f1b994210212f236b998a332995.tar.bz2
libstdc++: Fix forwarding in __take/drop_of_repeat_view [PR112453]
We need to respect the value category of the repeat_view passed to these two functions when accessing the view's _M_value member. This revealed that the space-efficient partial specialization of __box lacks && overloads of operator* to match those of the primary template (inherited from std::optional). PR libstdc++/112453 libstdc++-v3/ChangeLog: * include/std/ranges (__detail::__box<_Tp>::operator*): Define && overloads as well. (__detail::__take_of_repeat_view): Forward __r when accessing its _M_value member. (__detail::__drop_of_repeat_view): Likewise. * testsuite/std/ranges/repeat/1.cc (test07): New test. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/std')
-rw-r--r--libstdc++-v3/testsuite/std/ranges/repeat/1.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
index 3063640..0f6e551 100644
--- a/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/repeat/1.cc
@@ -2,6 +2,7 @@
#include <ranges>
#include <algorithm>
+#include <memory>
#include <testsuite_hooks.h>
#if __cpp_lib_ranges_repeat != 202207L
@@ -137,6 +138,17 @@ test06()
static_assert( requires { views::repeat(move_only{}, 2); } );
}
+void
+test07()
+{
+ // PR libstdc++/112453
+ auto t1 = std::views::repeat(std::make_unique<int>(5)) | std::views::take(2);
+ auto d1 = std::views::repeat(std::make_unique<int>(5)) | std::views::drop(2);
+
+ auto t2 = std::views::repeat(std::make_unique<int>(5), 4) | std::views::take(2);
+ auto d2 = std::views::repeat(std::make_unique<int>(5), 4) | std::views::drop(2);
+}
+
int
main()
{
@@ -146,4 +158,5 @@ main()
static_assert(test04());
test05();
test06();
+ test07();
}