Prev: Temporaries passed to constructor yield invalid member references
Next: Temporaries passed to constructor yield invalid member references
From: Jesse Perla on 30 May 2010 06:08 On May 29, 7:39 pm, Mark Zaytsev <mark.zayt...(a)gmail.com> wrote: > When you pass function you > a. pass pointer to standalone function -- no need to create excessive > ref > b. pass functor, which is usually stateless -- no need to create ref > to 0-sized object Alas, my functors have a large size which is part of the problem. > bottom line -- it more efficient to pass function by value I guess part of my question is whether modern compilers will generate pretty much the same code after optimization for these 2 issues even if it is const&. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Daniel Krügler on 14 Jun 2010 23:48
On 15 Jun., 11:19, Dragan Milenkovic <dra...(a)plusplus.rs> wrote: > Jesse Perla wrote: > > On May 29, 7:39 pm, Mark Zaytsev <mark.zayt...(a)gmail.com> wrote: > > >> When you pass function you > >> a. pass pointer to standalone function -- no need to create excessive > >> ref > >> b. pass functor, which is usually stateless -- no need to create ref > >> to 0-sized object > > > Alas, my functors have a large size which is part of the problem. > > Would creating a reference counting functor that delegates to your > existing overgrown functors help? Or even simpler by wrapping a reference to the expensive functor within a functor delegate, e.g. boost::reference_wrapper or std::reference_wrapper (C++0x) might help. HTH & Greeetings from Bremen, Daniel Kr�gler -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |