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.
This commit is contained in:
Jonathan Wakely 2024-07-11 21:23:15 +01:00 committed by Jonathan Wakely
parent 79d3f17b07
commit 43763bd75f
No known key found for this signature in database

View File

@ -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>> );