template <class T, class... Types>
std::add_pointer_t<T> get_if(variant<Types...> *pv);
template <class T, class... Types>
std::add_pointer_t<const T> get_if(const variant<Types...> *pv);
nullptr. Does nullptr argument makes any sense at all?dynamic_castinterface?From: Axel Naumann <Axel.Naumann (at) cern.ch>
Sent: Thursday, October 06, 2016 10:35 AM
To: Victor Dyachenko <victor.dyachenko (at) gmail.com>
Subject: Re: Fwd: Why does std::get_if(std::variant) take pointer as an
argument instead of reference?
Hi Victor,
I think the reason was pointer-in, pointer-out symmetry, which you could indeed
describe as "mimic dynamic_cast". I find that a strong reason.
The reduction in efficiency from the nullptr check is minimal given that the
function needs a runtime check for the index anyway. We could have made it a
pre-condition but then get_if couldn't be noexcept anymore.
The most performant and recommended interface is visitation.
Cheers, Axel
On 10/06/2016 09:25 AM, Victor Dyachenko wrote: