Skip to content

Commit eb1d9f0

Browse files
committed
P3450R1 Extend std::is_within_lifetime
Fixes NB US 82-145 (C++26 CD).
1 parent fda5e37 commit eb1d9f0

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

source/meta.tex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@
647647

648648
// \ref{meta.const.eval}, constant evaluation context
649649
constexpr bool is_constant_evaluated() noexcept;
650-
consteval bool is_within_lifetime(const auto*) noexcept;
650+
template<class U=void, class T>
651+
consteval bool is_within_lifetime(const T*) noexcept;
651652
}
652653
\end{codeblock}
653654

@@ -2844,14 +2845,21 @@
28442845

28452846
\indexlibraryglobal{is_within_lifetime}%
28462847
\begin{itemdecl}
2847-
consteval bool is_within_lifetime(const auto* p) noexcept;
2848+
template<class U=void, class T>
2849+
consteval bool is_within_lifetime(const T* p) noexcept;
28482850
\end{itemdecl}
28492851

28502852
\begin{itemdescr}
2853+
\pnum
2854+
\mandates
2855+
\tcode{static_cast<const volatile U*>(p)} is well-formed.
2856+
28512857
\pnum
28522858
\returns
28532859
\tcode{true} if \tcode{p} is a pointer to an object that is
2854-
within its lifetime\iref{basic.life}; otherwise, \tcode{false}.
2860+
within its lifetime\iref{basic.life} and
2861+
\tcode{static_cast<const volatile U*>(p)} is a constant subexpression;
2862+
otherwise, \tcode{false}.
28552863

28562864
\pnum
28572865
\remarks

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@
749749
#define @\defnlibxname{cpp_lib_is_sufficiently_aligned}@ 202411L // freestanding, also in \libheader{memory}
750750
#define @\defnlibxname{cpp_lib_is_swappable}@ 201603L // freestanding, also in \libheader{type_traits}
751751
#define @\defnlibxname{cpp_lib_is_virtual_base_of}@ 202406L // freestanding, also in \libheader{type_traits}
752-
#define @\defnlibxname{cpp_lib_is_within_lifetime}@ 202306L // freestanding, also in \libheader{type_traits}
752+
#define @\defnlibxname{cpp_lib_is_within_lifetime}@ 202603L // freestanding, also in \libheader{type_traits}
753753
#define @\defnlibxname{cpp_lib_jthread}@ 201911L // also in \libheader{stop_token}, \libheader{thread}
754754
#define @\defnlibxname{cpp_lib_latch}@ 201907L // also in \libheader{latch}
755755
#define @\defnlibxname{cpp_lib_launder}@ 201606L // freestanding, also in \libheader{new}

0 commit comments

Comments
 (0)