If compiler support for exceptions is turned off, usually via -fno-exceptions command line switch on gcc/clang, then std::variant can never be in the valueless_by_exception state. Thus, you should then be able to call std::visit<>() or std::get<>() without them doing the test for empty or having them call throw.
As it stands now, you can't compile variant without having exception support enabled.
If compiler support for exceptions is turned off, usually via
-fno-exceptions
command line switch ongcc
/clang
, thenstd::variant
can never be in thevalueless_by_exception
state. Thus, you should then be able to callstd::visit<>()
orstd::get<>()
without them doing the test for empty or having them callthrow
.As it stands now, you can't compile
variant
without having exception support enabled.