3 ms·
No doubt that std::visit appears to be a mess but why not call std::get<a_type>(a_variant) and trap bad_variant_access exceptions? It would still be a bit anno
by makecheck 9y ago
No doubt that std::visit appears to be a mess but why not call std::get<a_type>(a_variant) and trap bad_variant_access exceptions? It would still be a bit annoying to exception-wrap each attempt but it seems cleaner than any of the std::visit alternatives.
- MontagFTB 9y agoUsing exceptions as flow control is an anti-pattern in many modern C++ developer circles. It would also be excessively expensive.