Hi there,
As far as I looked at the code of boost::any currently it uses boost::typeindex for the cast functionality.
When the RTT information is turned off via -fno-rtti this causes the cast to do strcmp internally (link to godbolt) and leads to less efficient code than the libstdc++ implementation which does only function pointer comparison in this case (link to the implementation).
And boost::any already uses similar technique with function pointer for its internal operations.
So, my questions are:
- Is there some downside, that you can think of, in the
libstdc++ approach versus the boost::any/typeindex approach? Can the comparison of the function pointer lead to wrong casts in some edge cases?
- Assuming that the
libstdc++ approach has no downsides, is there an interest for changing the implementation of boost::any?
Regards,
Pavel.