std::is_within_lifetime

< cpp‎ | types
Defined in header <type_traits>
template< class T >
consteval bool is_within_lifetime( const T* p ) noexcept;
(since C++26)

Determines whether the pointer p points to an object that is within its lifetime. During the evaluation of an expression E as a core constant expression, a call to is_within_lifetime is ill-formed unless p points to an object that is usable in constant expressions or whose complete object’s lifetime began within E.

Parameters

p - pointer to detect

Return value

true if pointer p points to an object that is within its lifetime; otherwise false.

Example