Created on 2024-08-09.00:00:00 last changed 1 month ago
Proposed resolution:
This wording is relative to N4988.
Modify [meta.type.synop], header <type_traits> synopsis, as indicated:
[…] // [meta.const.eval], constant evaluation context constexpr bool is_constant_evaluated() noexcept; template<class T> consteval bool is_within_lifetime(const Tauto*) noexcept;
Modify [meta.const.eval] as indicated:
template<class T> consteval bool is_within_lifetime(const Tauto* p) noexcept;-?- Mandates: is_object_v<T> is true.
-3- Returns: true if p is a pointer to an object that is within its lifetime ([basic.life]); otherwise, false. -4- Remarks: During the evaluation of an expression E as a core constant expression, a call to this function is ill-formed unless p points to an object that is usable in constant expressions or whose complete object's lifetime began within E.
[ 2025-10-14; Reflector poll ]
Set priority to 3 after reflector poll.
"What about `void*`, should that be allowed? The compiler should know which union member the `void*` came from, as this is only using during constant evaluation."
"NAD, a function could have its lifetime constrained by a dynamic loader, so it seems wrong to assume that taling of function lifetimes makes no sense."
int f(); std::is_within_lifetime<int()>(f);
This is currently well-formed, and only fails when evaluated because is_within_lifetime is not constrained. However talking of lifetime of a non-object does not make sense, and the lack of constraint makes the implementation and use of that function and underlying built-in more convoluted than necessary.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-10-14 21:30:14 | admin | set | messages: + msg15166 |
| 2024-08-11 11:03:50 | admin | set | messages: + msg14322 |
| 2024-08-09 00:00:00 | admin | create | |