File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
tests/std/tests/Dev11_0863628_atomic_compare_exchange Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2123,6 +2123,7 @@ public:
2123
2123
2124
2124
using _Base::_Base;
2125
2125
2126
+ template <class _Uty = _Ty, enable_if_t<is_default_constructible_v<_Uty>, int> = 0>
2126
2127
constexpr atomic() noexcept(is_nothrow_default_constructible_v<_Ty>) : _Base() {}
2127
2128
2128
2129
atomic(const atomic&) = delete;
Original file line number Diff line number Diff line change 12
12
#include < cstdint>
13
13
#include < cstdlib>
14
14
#include < cstring>
15
+ #include < functional>
15
16
#include < limits>
16
17
#include < new>
17
18
#include < type_traits>
18
19
19
-
20
20
using namespace std ;
21
21
22
22
#define STATIC_ASSERT (...) static_assert (__VA_ARGS__, #__VA_ARGS__)
@@ -438,6 +438,17 @@ STATIC_ASSERT(atomic<void*>::is_always_lock_free);
438
438
STATIC_ASSERT (atomic<int (*)(int )>::is_always_lock_free);
439
439
#endif // _HAS_CXX17
440
440
441
+ // Also test LWG-4169 std::atomic<T>'s default constructor should be constrained
442
+ // (backported to C++14/17 modes as we backported P0883R2)
443
+ STATIC_ASSERT (is_default_constructible_v<atomic<int >>);
444
+ STATIC_ASSERT (is_default_constructible_v<atomic<bool >>);
445
+ STATIC_ASSERT (is_default_constructible_v<atomic<void *>>);
446
+ STATIC_ASSERT (is_default_constructible_v<atomic<X>>);
447
+ STATIC_ASSERT (is_default_constructible_v<atomic<Y>>);
448
+ STATIC_ASSERT (!is_default_constructible_v<atomic<reference_wrapper<int >>>);
449
+ STATIC_ASSERT (!is_default_constructible_v<atomic<reference_wrapper<const int >>>);
450
+ STATIC_ASSERT (!is_default_constructible_v<atomic<reference_wrapper<int ()>>>);
451
+
441
452
442
453
// Also test P0418R2 atomic compare_exchange memory_order Requirements
443
454
void test_compare_exchange_relaxed_memory_orders () {
You can’t perform that action at this time.
0 commit comments