aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-10-26 21:24:58 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-10-27 20:05:46 +0000
commitf1c844be5202f4be446f165d9a7625eb7ec4c5b4 (patch)
tree0614d2af2dd8203db576c8bab64bc4ef5e87ff32 /libstdc++-v3/testsuite
parent8e6cc1e7cdbb431a0950e491ed2830213f3ad81b (diff)
downloadgcc-f1c844be5202f4be446f165d9a7625eb7ec4c5b4.zip
gcc-f1c844be5202f4be446f165d9a7625eb7ec4c5b4.tar.gz
gcc-f1c844be5202f4be446f165d9a7625eb7ec4c5b4.tar.bz2
libstdc++: Fix std::vector<bool>::emplace to forward parameter
If the parameter is not lvalue-convertible to bool then the current code will fail to compile. The parameter should be forwarded to restore the original value category. libstdc++-v3/ChangeLog: * include/bits/stl_bvector.h (emplace_back, emplace): Forward parameter pack to preserve value category. * testsuite/23_containers/vector/bool/emplace_rvalue.cc: New test.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/bool/emplace_rvalue.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/emplace_rvalue.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/emplace_rvalue.cc
new file mode 100644
index 0000000..5dea242
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/emplace_rvalue.cc
@@ -0,0 +1,24 @@
+// { dg-do compile { target c++11 } }
+
+#include <vector>
+
+struct S
+{
+ explicit operator bool() &&;
+};
+
+void
+test_emplace_back()
+{
+ S s;
+ std::vector<bool> v;
+ v.emplace_back(std::move(s));
+}
+
+void
+test_emplace()
+{
+ S s;
+ std::vector<bool> v;
+ v.emplace(v.begin(), std::move(s));
+}