[libcxx-commits] [libcxx] [libcxx] P0718R2: Implementation of std::atomic<shared_ptr<T>> and std::atomic<weak_ptr<T>> (PR #194215)

Vladislav Semykin via libcxx-commits libcxx-commits at lists.llvm.org
Sat May 2 05:35:42 PDT 2026


================
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++20
+// UNSUPPORTED: no-threads
+
+// static constexpr bool is_always_lock_free;
+// bool is_lock_free() const noexcept;
+
+#include <atomic>
+#include <memory>
+
+#include "../atomic_smart_ptr_test_types.h"
+#include "test_macros.h"
+
+template <class T>
+void check() {
+  using A = std::atomic<std::shared_ptr<T>>;
+
+  static_assert(std::same_as<decltype(A::is_always_lock_free), const bool>);
+  static_assert(!static_cast<bool>(A::is_always_lock_free));
+
+  const A asp;
+  std::same_as<bool> decltype(auto) lf = asp.is_lock_free();
+  (void)lf;
+  ASSERT_NOEXCEPT(A::is_always_lock_free);
+  ASSERT_NOEXCEPT(asp.is_lock_free());
----------------
ViNN280801 wrote:

> Why is this test *.compile.pass.cpp instead of a runtime test .pass.cpp?
> Have you checked the documentation when to use .compile.pass.cpp, .verify.pass.cpp, etc. ? Also I think compile and verify tests don't need main().

Yes, [I do](https://libcxx.llvm.org/TestingLibcxx.html), but it's my inattention, sorry, you are absolutely right, my fault.

https://github.com/llvm/llvm-project/pull/194215


More information about the libcxx-commits mailing list