You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To check which type a variant holds, both v.which() == x and v.type() == typeid(T) are used,, and i'm not keen on either. The options are:
v.which(): Fast, small code, but it would be better to not have to find the type index.
v.type(): Slow (often ends up as a string compare), lots of code, and implies use of RTTI.
boost::get<T>(&v) != nullptr: Arguably the proper way to do it, but generates more code than v.which() on gcc, and MSVC fails to optimise it and generates a whole bunch of nonsense
use a visitor: similar code to get (as boost implements get with a visitor)
I think we should replace these with v.which() and some template magic to find the right index:
If you turn the "library functions" filter off on MSVC you can see all the extra stuff generated for some options; this goes away if you remove the non-which options.
The text was updated successfully, but these errors were encountered:
To check which type a variant holds, both
v.which() == x
andv.type() == typeid(T)
are used,, and i'm not keen on either. The options are:v.which()
: Fast, small code, but it would be better to not have to find the type index.v.type()
: Slow (often ends up as a string compare), lots of code, and implies use of RTTI.boost::get<T>(&v) != nullptr
: Arguably the proper way to do it, but generates more code thanv.which()
on gcc, and MSVC fails to optimise it and generates a whole bunch of nonsenseI think we should replace these with
v.which()
and some template magic to find the right index:https://gcc.godbolt.org/z/ed3zv1b9M
If you turn the "library functions" filter off on MSVC you can see all the extra stuff generated for some options; this goes away if you remove the non-which options.
The text was updated successfully, but these errors were encountered: