libstdc++: Add std::atomic<shared_ptr>(nullptr_t) constructor (LWG 3661)

This DR was approved at the February 2022 plenary.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (atomic<shared_ptr>): Add
	constructor for constant initialization from nullptr_t.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
	Check for new constructor.
This commit is contained in:
Jonathan Wakely 2022-04-25 18:25:07 +01:00
parent e3c5e8360b
commit 41ccd683f0
2 changed files with 6 additions and 0 deletions

View File

@ -573,6 +573,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr atomic() noexcept = default;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 3661. constinit atomic<shared_ptr<T>> a(nullptr); should work
constexpr atomic(nullptr_t) noexcept : atomic() { }
atomic(shared_ptr<_Tp> __r) noexcept
: _M_impl(std::move(__r))
{ }

View File

@ -18,6 +18,8 @@
// Check constexpr constructor.
constinit std::atomic<std::shared_ptr<int>> a;
// LWG 3661. constinit atomic<shared_ptr<T>> a(nullptr); should work
constinit std::atomic<std::shared_ptr<int>> a2 = nullptr;
void
test_is_lock_free()