You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In many situations, it'd be beneficial to have an error Status which was copyable without using the heap. For example, this is a frequent pain point with Result. We want Result to be default constructible even if T isn't, so a defaulted Result is an error but this requires heap allocating a Status::State which we immediately overwrite. Similarly, if the value or error is moved out of a Result we'd like to avoid managing the stored object and wind up heap allocating a flag.
Allowing some Status objects to have static lifetime (for example, by tagging the state_ pointer or adding bool Status::State::is_static) should not have an effect on the critical hot paths of moving a status or skipping deletion of ok status. Copying will get slightly slower since we need to branch on state_->is_static, but that's already quite slow due to heap interaction.
Component(s)
C++
The text was updated successfully, but these errors were encountered:
Describe the enhancement requested
In many situations, it'd be beneficial to have an error Status which was copyable without using the heap. For example, this is a frequent pain point with Result. We want Result to be default constructible even if T isn't, so a defaulted Result is an error but this requires heap allocating a Status::State which we immediately overwrite. Similarly, if the value or error is moved out of a Result we'd like to avoid managing the stored object and wind up heap allocating a flag.
Allowing some Status objects to have static lifetime (for example, by tagging the
state_
pointer or addingbool Status::State::is_static
) should not have an effect on the critical hot paths of moving a status or skipping deletion of ok status. Copying will get slightly slower since we need to branch onstate_->is_static
, but that's already quite slow due to heap interaction.Component(s)
C++
The text was updated successfully, but these errors were encountered: