-
Notifications
You must be signed in to change notification settings - Fork 4
Description
There are certain operations that are only valid for implicit-lifetime types. In particular, in certain situations the lifetime of an object of implicit- lifetime type can be implicitly started by operations such as malloc, where otherwise the code would be undefined behaviour due to a violation of the C++ object lifetime rules. Additionally, in C++23 we are adding the possibility to start the lifetime of such objects explicitly with std::start_lifetime_as<T>
[P2590R2].
Unfortunately, C++ lacks the ability to programmatically check whether a type is an implicit-lifetime type, and to constrain functions using such operations to only be valid for such types. This is particularly important to help catch a possible regression: if a type that was once implicit-lifetime mistakenly loses that property as a part of a change, this silently turns previously correct code into undefined behaviour. To fix this issue, we should add the type trait std::is_implicit_lifetime<T>
, as proposed by P2674R0. Because this is necessary to avoid a class of bugs, we consider this proposal a bugfix, rather than a new feature request, and recommend to adopt it in the C++23 timeframe.
Adopt the changes proposed in P2674R0.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status