C++26: Std:Is_within_lifetime
sandordargo.com
C++26: Std:Is_within_lifetime
1–10 of 75 posts
Re: C++26: Std:Is_within_lifetime
#2Re: C++26: Std:Is_within_lifetime
#3Still, it's a wasted opportunity not to have a language-level overload to the `switch` statement that allows nice pattern matching. Even with std::is_within_lifetime C++ unions are prone to errors and hard to work with.
Re: C++26: Std:Is_within_lifetime
#4Doing so takes the same space as a bool, and could be wrapped in a class if desired to provide a nicer interface.
Re: C++26: Std:Is_within_lifetime
#5Re: C++26: Std:Is_within_lifetime
#6Re: C++26: Std:Is_within_lifetime
#7Re: C++26: Std:Is_within_lifetime
#8The problem pointed out in the article seems a little silly. We're adding an entire language feature because someone wanted an optional bool class? Why not just create a uint8_t with three values: OPTIONAL_BOOL_FASLE, OPTIONAL_BOOL_TRUE, OPTIONAL_BOOL_UNDEFINED? Doing so takes the same space as a bool, and could be wrapped in a class if desired to provide a nicer interface.
I'm (fairly) sure there's a good reason for that language feature, but the justification the blog article gives is super weak.
Re: C++26: Std:Is_within_lifetime
#9Is this the first type of sum-type option choosing statement present for C++ unions? I've been waiting for this feature since the year 1978. Still, it's a wasted opportunity not to have a language-level overload to the `switch` statement that allows nice pattern matching. Even with std::is_within_lifetime C++ unions are prone to errors and hard to work with.