-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
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 thanv.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:
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.
Metadata
Metadata
Assignees
Labels
No labels