[all-commits] [llvm/llvm-project] 2527b0: [libc++] P2641R4: Checking if a `union` alternativ...

Nikolas Klauser via All-commits all-commits at lists.llvm.org
Sun Nov 2 01:30:53 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2527b071ba2e39fdd62eeb73b89318468595c316
      https://github.com/llvm/llvm-project/commit/2527b071ba2e39fdd62eeb73b89318468595c316
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2025-11-02 (Sun, 02 Nov 2025)

  Changed paths:
    M libcxx/docs/FeatureTestMacroTable.rst
    M libcxx/include/CMakeLists.txt
    A libcxx/include/__type_traits/is_within_lifetime.h
    M libcxx/include/module.modulemap.in
    M libcxx/include/type_traits
    M libcxx/include/version
    M libcxx/modules/std/type_traits.inc
    A libcxx/test/libcxx/utilities/meta/is_within_lifetime.verify.cpp
    M libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp
    M libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
    A libcxx/test/std/utilities/meta/meta.const.eval/is_within_lifetime.compile.pass.cpp
    M libcxx/utils/generate_feature_test_macro_components.py

  Log Message:
  -----------
  [libc++] P2641R4: Checking if a `union` alternative is active (`std::is_within_lifetime`) (#165243)

<https://wg21.link/P2641R4>

Implements the C++26 function in `<type_traits>` [meta.const.eval] (and
the corresponding feature test macro `__cpp_lib_is_within_lifetime`)

```c++
template<class T>
  consteval bool is_within_lifetime(const T*) noexcept;
```

This is done with the `__builtin_is_within_lifetime` builtin added to
Clang 20 by #91895 / 2a07509c8d3c8b5b2c88e4f73dde0071bf506870. This is
not (currently) available with GCC.

This implementation has provisions for LWG4138
<https://cplusplus.github.io/LWG/issue4138> where it is ill-formed to
instantiate `is_within_lifetime<T>` with a function type `T`.

Closes #105381

Co-authored-by: Mital Ashok <mital at mitalashok.co.uk>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list