|
Boost Users : |
Subject: Re: [Boost-users] boost::bind replacements
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-09-17 22:59:07
on Sat Sep 17 2011, "Littlefield, Tyler" <tyler-AT-tysdomain.com> wrote:
> On 9/17/2011 1:06 PM, Dmitriy Matison wrote:
>> Hello,
>
>>
>> Would you, please, tell in more detail about the overhead in binary
>> size? What are approximate numbers of it? And how badly the
>> compilation time decreases? I used boost::bind a lot, but haven't
>> noticed that the overhead makes so much difference. Opposite example
>> would be valuable.
>>
> I switched to boost::bind because I use an event system, as I pointed
> out earlier. I liked being able to bind to methods and static members,
> rather than just global functions with a function pointer. The
> overhead could very well be with boost::function, since every time I
> add a typedef I get a lot of overhead there.
> I can't rip it out and show exactly how much compilation time
> decreases because it's an integral part of my system now. I don't
> think the compilation time has went up by a huge factor, but the
> binary size certainly has. This is both with -O3 and -O0, using g++.
>> Thanks,
>> Dmitriy.
You can measure how much binary size overhead each bind costs you by
replacing it with a hand-rolled function object that does the same
thing, and comparing object code size. These are usually fairly easy
(if tedious) to write. It's just a struct whose constructor stores
everything you're currently passing to the bind that isn't a
placeholder, and whose function call operator invokes the underlying
object.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net