Does boost::any need RTTI?
Asked Answered
B

1

3

On the Boost web site I found no information regarding the use or RTTI by boost::any.

I read in a few places that this is a requirement, but then I built a simple test project, and it builds both with and without RTTI.

So, is RTTI, with its performance and memory issues, needed by boost::any and similar classes?

Belonging answered 12/7, 2016 at 9:10 Comment(1)
I've just tried to build a simple program with boost_any, and an executable built with -fno-rtti was actually larger than one built without. I have no idea what it means.Smudge
P
5

Since boost 1.57 RTTI is not needed for boost::any. Rememeber that all objects used as boost::any must by copyable.

https://svn.boost.org/trac/boost/ticket/10346

Phreno answered 12/7, 2016 at 9:17 Comment(2)
I must say that if compilers would not just disallow typeid with RTTI disabled and allowed its use in non-polymorfic context, it would work without need to reinvent the wheel.Hogle
@paweldac: OK, that is the reason of the contradicting information I found.Belonging

© 2022 - 2024 — McMap. All rights reserved.