diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-07-12 16:09:34 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-07-12 18:35:27 +0100 |
commit | 9d4393af9d2b37b78eb5b1f84f5d4da3a6f7fba6 (patch) | |
tree | 2a130a418f2583104f5ea1523714780cc200cf26 /libstdc++-v3/testsuite/23_containers | |
parent | 3f2338b4706cdc53ab276b9a5fed7f6927404f07 (diff) | |
download | gcc-9d4393af9d2b37b78eb5b1f84f5d4da3a6f7fba6.tar.gz |
libstdc++: Constrain std::as_writable_bytes [PR101411]
The std::as_writable_bytes function should be constrained to only accept
writable spans. Currently it can be called but then gives an error in
the function body.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101411
* include/std/span (as_writable_bytes): Add requires-clause.
* testsuite/23_containers/span/101411.cc: New test.
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers')
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/span/101411.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/span/101411.cc b/libstdc++-v3/testsuite/23_containers/span/101411.cc new file mode 100644 index 00000000000..05bdd3badbd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/span/101411.cc @@ -0,0 +1,15 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { xfail c++20 } } +#include <span> + +// PR libstdc++/101411 + +void f(std::span<const int> s) +{ + std::as_writable_bytes(s); // { dg-error "no matching function" } +} + +void f1(std::span<const int, 1> s) +{ + std::as_writable_bytes(s); // { dg-error "no matching function" } +} |