| 1 |
// Copyright (C) 2022-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do compile { target c++23 } } |
| 19 |
|
| 20 |
#include <atomic> |
| 21 |
#include <stdfloat> |
| 22 |
|
| 23 |
#if defined(__STDCPP_FLOAT16_T__) |
| 24 |
void |
| 25 |
test01() |
| 26 |
{ |
| 27 |
using A = std::atomic<std::float16_t>; |
| 28 |
static_assert( std::is_standard_layout_v<A> ); |
| 29 |
static_assert( !std::is_trivially_default_constructible_v<A> ); |
| 30 |
static_assert( std::is_trivially_destructible_v<A> ); |
| 31 |
static_assert( std::is_same_v<A::value_type, std::float16_t> ); |
| 32 |
static_assert( std::is_same_v<A::difference_type, A::value_type> ); |
| 33 |
static_assert( !std::is_copy_constructible_v<A> ); |
| 34 |
static_assert( !std::is_move_constructible_v<A> ); |
| 35 |
static_assert( !std::is_copy_assignable_v<A> ); |
| 36 |
static_assert( !std::is_move_assignable_v<A> ); |
| 37 |
static_assert( !std::is_assignable_v<volatile A&, const A&> ); |
| 38 |
} |
| 39 |
#endif |
| 40 |
|
| 41 |
#if defined(__STDCPP_FLOAT32_T__) |
| 42 |
void |
| 43 |
test02() |
| 44 |
{ |
| 45 |
using A = std::atomic<std::float32_t>; |
| 46 |
static_assert( std::is_standard_layout_v<A> ); |
| 47 |
static_assert( !std::is_trivially_default_constructible_v<A> ); |
| 48 |
static_assert( std::is_trivially_destructible_v<A> ); |
| 49 |
static_assert( std::is_same_v<A::value_type, std::float32_t> ); |
| 50 |
static_assert( std::is_same_v<A::difference_type, A::value_type> ); |
| 51 |
static_assert( !std::is_copy_constructible_v<A> ); |
| 52 |
static_assert( !std::is_move_constructible_v<A> ); |
| 53 |
static_assert( !std::is_copy_assignable_v<A> ); |
| 54 |
static_assert( !std::is_move_assignable_v<A> ); |
| 55 |
static_assert( !std::is_assignable_v<volatile A&, const A&> ); |
| 56 |
} |
| 57 |
#endif |
| 58 |
|
| 59 |
#if defined(__STDCPP_FLOAT64_T__) |
| 60 |
void |
| 61 |
test03() |
| 62 |
{ |
| 63 |
using A = std::atomic<std::float64_t>; |
| 64 |
static_assert( std::is_standard_layout_v<A> ); |
| 65 |
static_assert( !std::is_trivially_default_constructible_v<A> ); |
| 66 |
static_assert( std::is_trivially_destructible_v<A> ); |
| 67 |
static_assert( std::is_same_v<A::value_type, std::float64_t> ); |
| 68 |
static_assert( std::is_same_v<A::difference_type, A::value_type> ); |
| 69 |
static_assert( !std::is_copy_constructible_v<A> ); |
| 70 |
static_assert( !std::is_move_constructible_v<A> ); |
| 71 |
static_assert( !std::is_copy_assignable_v<A> ); |
| 72 |
static_assert( !std::is_move_assignable_v<A> ); |
| 73 |
static_assert( !std::is_assignable_v<volatile A&, const A&> ); |
| 74 |
} |
| 75 |
#endif |
| 76 |
|
| 77 |
#if defined(__STDCPP_FLOAT128_T__) |
| 78 |
void |
| 79 |
test04() |
| 80 |
{ |
| 81 |
using A = std::atomic<std::float128_t>; |
| 82 |
static_assert( std::is_standard_layout_v<A> ); |
| 83 |
static_assert( !std::is_trivially_default_constructible_v<A> ); |
| 84 |
static_assert( std::is_trivially_destructible_v<A> ); |
| 85 |
static_assert( std::is_same_v<A::value_type, std::float128_t> ); |
| 86 |
static_assert( std::is_same_v<A::difference_type, A::value_type> ); |
| 87 |
static_assert( !std::is_copy_constructible_v<A> ); |
| 88 |
static_assert( !std::is_move_constructible_v<A> ); |
| 89 |
static_assert( !std::is_copy_assignable_v<A> ); |
| 90 |
static_assert( !std::is_move_assignable_v<A> ); |
| 91 |
static_assert( !std::is_assignable_v<volatile A&, const A&> ); |
| 92 |
} |
| 93 |
#endif |
| 94 |
|
| 95 |
#if defined(__STDCPP_BFLOAT16_T__) |
| 96 |
void |
| 97 |
test05() |
| 98 |
{ |
| 99 |
using A = std::atomic<std::bfloat16_t>; |
| 100 |
static_assert( std::is_standard_layout_v<A> ); |
| 101 |
static_assert( !std::is_trivially_default_constructible_v<A> ); |
| 102 |
static_assert( std::is_trivially_destructible_v<A> ); |
| 103 |
static_assert( std::is_same_v<A::value_type, std::bfloat16_t> ); |
| 104 |
static_assert( std::is_same_v<A::difference_type, A::value_type> ); |
| 105 |
static_assert( !std::is_copy_constructible_v<A> ); |
| 106 |
static_assert( !std::is_move_constructible_v<A> ); |
| 107 |
static_assert( !std::is_copy_assignable_v<A> ); |
| 108 |
static_assert( !std::is_move_assignable_v<A> ); |
| 109 |
static_assert( !std::is_assignable_v<volatile A&, const A&> ); |
| 110 |
} |
| 111 |
#endif |