Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -4003,6 +4003,10 @@ public:
store(_STD move(_Value));
}

void operator=(nullptr_t) noexcept {
store(nullptr);
}

~atomic() {
const auto _Rep = this->_Repptr._Unsafe_load_relaxed();
if (_Rep) {
Expand Down
9 changes: 9 additions & 0 deletions tests/std/tests/P0718R2_atomic_smart_ptrs/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <thread>
#include <type_traits>
#ifdef _DEBUG
#include <crtdbg.h>
#endif // _DEBUG
Expand Down Expand Up @@ -632,6 +634,13 @@ int main() {
ensure_member_calls_compile<atomic<shared_ptr<int[2][2]>>>();
ensure_member_calls_compile<atomic<weak_ptr<int[2][2]>>>();

// LWG-3893: LWG 3661 broke atomic<shared_ptr<T>> a; a = nullptr;
static_assert(is_nothrow_assignable_v<atomic<shared_ptr<bool>>, nullptr_t>);
static_assert(is_nothrow_assignable_v<atomic<shared_ptr<int>>, nullptr_t>);
static_assert(is_nothrow_assignable_v<atomic<shared_ptr<int[]>>, nullptr_t>);
static_assert(is_nothrow_assignable_v<atomic<shared_ptr<int[][2]>>, nullptr_t>);
static_assert(is_nothrow_assignable_v<atomic<shared_ptr<int[2][2]>>, nullptr_t>);

#ifdef _DEBUG
sptr0 = {};
sptr1 = {};
Expand Down