4 ms·
I think it can guarantee full coverage. You just need an else branch with `static_assert(false)` or something along those lines
by bvaldivielso 6y ago
I think it can guarantee full coverage. You just need an else branch with `static_assert(false)` or something along those lines
- jsnell 6y agoIf you need to put in the fallback "else" yourself, with no error or even warning if you forget to do so, it's not much of a guarantee :) (And thinking about this a bit more, there's presumably also the opposite case: if you add a branch for a type that's not a member of the variant / remove a type from a variant without updating all the visitors, it'd just happily compile with no indication that anything is wrong.)
- nyanpasu64 6y agostatic_assert(false) fails to compile even if it appears in an if-constexpr branch that isn't taken. You need a dependent false value, templated by the type passed into the lambda. And yes, C++ is an endless pit of horrors.