aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-07-11 21:23:15 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-07-12 00:08:16 +0100
commit43763bd75f1d37189ba08657a322e91d240e8cf3 (patch)
tree8c474ea9619e8f08b51847f8e7a97031782b0e4a
parent79d3f17b07884cc9486f5e6fb21beea97c153a55 (diff)
downloadgcc-43763bd75f1d37189ba08657a322e91d240e8cf3.zip
gcc-43763bd75f1d37189ba08657a322e91d240e8cf3.tar.gz
gcc-43763bd75f1d37189ba08657a322e91d240e8cf3.tar.bz2
libstdc++: Test that std::atomic_ref<bool> uses the primary template
The previous commit changed atomic_ref<bool> to not use the integral specialization. This adds a test to verify that change. We can't directly test that the primary template is used, but we can check that the member functions of the integral specializations are not present. libstdc++-v3/ChangeLog: * testsuite/29_atomics/atomic_ref/bool.cc: New test.
-rw-r--r--libstdc++-v3/testsuite/29_atomics/atomic_ref/bool.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/bool.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/bool.cc
new file mode 100644
index 0000000..4702932
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/bool.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++20 } }
+
+#include <atomic>
+
+template<class T> concept has_and = requires (T& a) { a &= false; };
+template<class T> concept has_or = requires (T& a) { a |= false; };
+template<class T> concept has_xor = requires (T& a) { a ^= false; };
+template<class T> concept has_fetch_add = requires (T& a) { a.fetch_add(true); };
+template<class T> concept has_fetch_sub = requires (T& a) { a.fetch_sub(true); };
+
+static_assert( not has_and<std::atomic_ref<bool>> );
+static_assert( not has_or<std::atomic_ref<bool>> );
+static_assert( not has_xor<std::atomic_ref<bool>> );
+static_assert( not has_fetch_add<std::atomic_ref<bool>> );
+static_assert( not has_fetch_sub<std::atomic_ref<bool>> );