2 Mar
2019
2 Mar
'19
8:49 p.m.
AMDG On 3/2/19 12:47 PM, Mathias Gaunard via Boost wrote:
On Fri, 1 Mar 2019 at 09:59, Peter Dimov via Boost
wrote: Kind of, but as written this implies that std::variant has no costs, which is not true. The checks for valueless do carry a cost. Each visit(), for example, starts with `if(valueless) throw`, which is not necessary in variant2.
That is not true. A typical implementation would just add an extra value to the switch, there is no extra branch.
That may be true in theory, but both libc++ and libstdc++ have if(__v.valueless_by_exception()) scattered everywhere. Not to mention that neither uses switch. In Christ, Steven Watanabe