Boost logo

Boost :

Subject: [boost] [variant2] Review of Variant2
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2019-04-09 02:42:47

I vote *ACCEPT*.


I consider it a shortcoming that std::variant does not have the
never-valueless guarantee of variant2. The point of variant<A,B> is that
after a successful initialization, it will either have a valid A or a valid
B. If I wanted to have to deal with some other alternative, I would have
specified a third type.

The main objection to the never-valueless semantics is that after a failed
assignment, the programmer could be surprised to find that the target
variant object may have switched from a valid value of the previously
stored type, to a valid value of one of the other alternative types. While
it is true that the change of type can be surprising, this is the good old
basic guarantee in action -- nothing less, nothing more.

I also like the addition of the narrowing operation subset<U...>, seems

*Did you try to use the library?*

I tried variant2 on Mac/clang.

*How much effort did you put into your evaluation?*

I spent a 3 hours reading the documentation and experimenting. I also tried
using expected<T, std::error_code> as a result type in LEAF.

*Are you knowledgeable about the problem domain?*


Boost list run by bdawes at, gregod at, cpdaniel at, john at