[libcxx-commits] [libcxx] [libc++] constexpr atomic and atomic_ref (PR #98765)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 14 03:33:57 PDT 2024


philnik777 wrote:

> > I'm not sure what you mean here with "how to make the constexpr support conditional". Allowing it only for C++26 seems like the right thing to do to me.
> 
> I mean this will work with clang with apropriate change, but libc++ is working with other compilers, so the support should be enabled conditionally `constexpr` conditionally so user won't get scary error about insides of `atomic<T>` if they will try to use it on compiler without atomic builtins support.

Ah, OK. Are there actually any errors generated? We're in a template, so that might not actually be a problem. If there are diagnostics I think we want something like
```c++
#if __has_constexpr_builtin(whatever)
#  define _LIBCPP_ATOMIC_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX26
#else
#  define _LIBCPP_ATOMIC_CONSTEXPR
#endif
```
and then just use `_LIBCPP_ATOMIC_CONSTEXPR` throughout instead of `_LIBCPP_CONSTEXPR_SINCE_CXX26`.

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


More information about the libcxx-commits mailing list