Boost logo

Boost :

Subject: Re: [boost] [function] Using boost::function when rtti is notavailable
From: Domagoj Saric (dsaritz_at_[hidden])
Date: 2009-12-15 17:34:40


"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:1A337E6AB7744D2D85BA1310B8188681_at_pdimov2...
> sp_typeinfo.hpp wasn't quite up to the task, but I fixed it, and changed
> function_base.hpp to use it. The relevant patches are:
>
> https://svn.boost.org/trac/boost/changeset/58127
> https://svn.boost.org/trac/boost/changeset/58128

if i'm not mistaken these changes/patches provide a 'proper'/'good enough'
typeid/type_info implementation to make the full (boost/tr1)::function
interface (including target<>()) available even for platforms/compilers that do
not provide RTTI/when BOOST_NO_TYPEID is defined?
this is great on its own but it seems that perhaps we need another related
macro...something like BOOST_EMULATED_TYPEID and BOOST_NO_TYPEID where the
latter would not try to emulate but completely disable RTTI related
functionality (where possible) ...
...boost::function is a perfect example to show the need/usefulness for this:
my real life project i used to test boost::function with has grown further
(with more functors that get assigned to boost::functions) and i recently
refactored it to no longer need boost::function at all but i could use plain
function pointers so i could better test the impact that the usage of
boost::function has on a/my binary...
here are the results (in bytes and in ascending order, aligned for fixed width
font):
( bf = boost::function 1.40, abf = my altered boost::function 1.40 )

plain_function_pointers 514.048
abf + BOOST_NO_TYPEID + assert_on_empty 537.600
abf + BOOST_NO_TYPEID 546.304
abf + assert_on_empty 635.904
abf 644.096
bf 660.992

it is obvious that RTTI/type information has the biggest role in bloating a
binary (atleast in use cases like mine with lots of template generated function
objects, that therefor have very long type names)

(i hadn't yet had time to upgrade to 1.41 with your patches to test that also)

(as argued/explained before the option to turn on/off the rtti features of
boost::function should be a local/on a case by case basis switch/a matter of
policy rather than a global switch/macro)

-- 
 "That men do not learn very much from the lessons of history is the most
important of all the lessons of history."
 Aldous Huxley

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk