[libcxx-commits] [libcxx] [libc++] P2530R3: Implementation of std::hazard_pointer (PR #218218)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 23 22:33:55 PDT 2026


================

----------------
Zingam wrote:

@MindSpectre I wanted to add but forgot: In libc++ we follow the wording of The Standard quite strictly, especially if there isn't a good reason to do otherwise. 

To illustrate what I write about: according to The Standard https://eel.is/c++draft/saferecl.hp#lib:try_protect,hazard_pointer
```c++
    if (__old != __ptr) {
      reset_protection();
    }
    return __old == __ptr;
but IMO your implementation is an acceptable improvement:
```c++
    if (__old != __ptr) {
      reset_protection();
      return false;
    }
    return true;
```
Yet, expect sometimes somebody to disagree :)

Also prefer the latest best practices and style. The library evolved over many years and not everything is consistent like tests, etc. so when possible we prefer to use latest language features vs macros (mainly in tests), latest best practices, etc. the coding guideline here: https://libcxx.llvm.org/CodingGuidelines.html

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


More information about the libcxx-commits mailing list