"Bill why do you hate optional<T&> so much?" Bill:
-
@thephd Pretty sure a lot of the folks who wanted optional<T&> were dogmatic about replacing pointers
. Of course with standardization rarely does everyone want something for the same reason.Kinda reminds me of what happened with string_view. Google wants it because they see 1% of fleet-wide CPU for Google being spent in strlen, so they want no brakes. Microsoft wants it because they're pushing GSL and want to shut down memory safety issues so they wanted it to bounds check.
Not sure how I feel about variant and expected. (Note that variant models a discriminated union and the core language forbids reference members of unions https://eel.is/c++draft/class.union#general-4 )
The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.
This works, really, but fails because tuple can hold a reference.
-
The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.
This works, really, but fails because tuple can hold a reference.
@Sdowney I'm not sure how useful such an iterator is, particularly given that variant and tuple probably want different answers on the rebind vs. assign-through question. (tuple must be assign-through for std::tie/std::forward_as_tuple et al. to work. But @thephd showed us that variant probably wants rebind instead?)
I know it's encouraging to think of optional<T> as variant<monostate, T> but assignment is one place I can't mentally make them agree