[libcxx-commits] [libcxx] [libc++] Use a custom once_flag implementation for locale::id::__get() (PR #212235)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 12 04:06:18 PDT 2026
================
@@ -563,9 +563,29 @@ void locale::facet::__on_zero_shared() noexcept { delete this; }
// locale::id
long locale::id::__get() {
- constinit static int32_t next_id = 0;
- call_once(__flag_, [&] { __id_ = __libcpp_atomic_add(&next_id, 1); });
- return __id_ - 1;
+ constexpr __id_type uninitialized = 0;
----------------
philnik777 wrote:
We could, but making it an enum class would mean we'd have to cast all over the place. I don't think that improve readability. If we don't make it an enum class I don't see why we'd want to move these to the header.
https://github.com/llvm/llvm-project/pull/212235
More information about the libcxx-commits
mailing list