| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
// { dg-add-options no_pch } |
| 3 |
// { dg-require-atomic-cmpxchg-word "PR libstdc++/114103" } |
| 4 |
|
| 5 |
#include <atomic> |
| 6 |
|
| 7 |
#ifndef __cpp_lib_atomic_lock_free_type_aliases |
| 8 |
# error "Feature test macro for lock-free type aliases is missing in <atomic>" |
| 9 |
#elif __cpp_lib_atomic_lock_free_type_aliases != 201907L |
| 10 |
# error "Feature test macro for lock-free type aliases has wrong value in <atomic>" |
| 11 |
#endif |
| 12 |
|
| 13 |
template<typename T> |
| 14 |
constexpr bool is_atomic_specialization = false; |
| 15 |
template<typename T> |
| 16 |
constexpr bool is_atomic_specialization<std::atomic<T>> = true; |
| 17 |
|
| 18 |
// The type aliases atomic_signed_lock_free and atomic_unsigned_lock_free |
| 19 |
// name specializations of atomic |
| 20 |
static_assert( is_atomic_specialization<std::atomic_signed_lock_free> ); |
| 21 |
static_assert( is_atomic_specialization<std::atomic_unsigned_lock_free> ); |
| 22 |
|
| 23 |
#include <type_traits> |
| 24 |
|
| 25 |
// ... whose template arguments are integral types, |
| 26 |
static_assert( std::is_integral_v<std::atomic_signed_lock_free::value_type> ); |
| 27 |
static_assert( std::is_integral_v<std::atomic_unsigned_lock_free::value_type> ); |
| 28 |
|
| 29 |
// ... respectively signed and unsigned, |
| 30 |
static_assert( std::is_signed_v<std::atomic_signed_lock_free::value_type> ); |
| 31 |
static_assert( std::is_unsigned_v<std::atomic_unsigned_lock_free::value_type> ); |
| 32 |
|
| 33 |
// and whose is_always_lock_free property is true. |
| 34 |
static_assert( std::atomic_signed_lock_free::is_always_lock_free ); |
| 35 |
static_assert( std::atomic_unsigned_lock_free::is_always_lock_free ); |