boost::bind replacements

Hello all: I really like boost::bind because I use an event system in my game engine, and it allows me to bind callbacks in classes, rather than having everything as global functions, like they were before. My problem is this. Boost::bind incurs a lot of overhead, both during compilation and in binary size. Is there any way to decrease this? If not, I'm curious if someone could explain how boost::bind works so that I can create my own? I understand function objects can hold function pointers and boost::bind returns a function object, but I'm really confused as to how placeholders work. -- Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud Sent from my toaster.

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.
Thanks,
Dmitriy.
On 17 September 2011 21:46, Littlefield, Tyler
Hello all: I really like boost::bind because I use an event system in my game engine, and it allows me to bind callbacks in classes, rather than having everything as global functions, like they were before. My problem is this. Boost::bind incurs a lot of overhead, both during compilation and in binary size. Is there any way to decrease this? If not, I'm curious if someone could explain how boost::bind works so that I can create my own? I understand function objects can hold function pointers and boost::bind returns a function object, but I'm really confused as to how placeholders work.
--
Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud
Sent from my toaster.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

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.
On 17 September 2011 21:46, Littlefield, Tyler
wrote: Hello all: I really like boost::bind because I use an event system in my game engine, and it allows me to bind callbacks in classes, rather than having everything as global functions, like they were before. My problem is this. Boost::bind incurs a lot of overhead, both during compilation and in binary size. Is there any way to decrease this? If not, I'm curious if someone could explain how boost::bind works so that I can create my own? I understand function objects can hold function pointers and boost::bind returns a function object, but I'm really confused as to how placeholders work.
--
Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud
Sent from my toaster.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Take care, Ty Web: http://tds-solutions.net The Aspen project: a light-weight barebones mud engine http://code.google.com/p/aspenmud Sent from my toaster.

on Sat Sep 17 2011, "Littlefield, Tyler"
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

My problem is this. Boost::bind incurs a lot of overhead, both during compilation and in binary size. Is there any way to decrease this?
Just out of curiousity, could you please provide exact benchmarks, i.e. what's the binary size with and without bind? By the way, what compiler do you use with what optimization settings?
participants (4)
-
Dave Abrahams
-
Dmitriy Matison
-
Igor R
-
Littlefield, Tyler