Boost logo

Boost :

Subject: Re: [boost] [outcome] To variant, or not to variant?
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-03 09:49:57


Vicente J. Botet Escriba wrote:

> If we had to define a monadic interface for std::variant<T,
> unexpected<E>>, I'm sure that the std::variant implementer would have a
> hidden narrow access to its elements and will not use neither get_if nor
> visit. Well, this is what I will do to avoid to have to ensure/check that
> there is no cost while using get_if/visit.

On gcc/clang there is no cost for using *get_if<> instead of a private
accessor, and depending on how get<> is written, there can be no cost to
using it as well. I did switch from get<> to private accessors within the
variant implementation, but that's mostly because I want to generate
aesthetically pleasing assembly on Compiler Explorer and not because there
is a measurable cost to using get<>.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk