|
Prev: Deletion of objects whose reference is holded in static map instances
Next: auto_ptr definition
From: jtorjo2007 on 25 Nov 2007 18:14 > I'm seeking comments about this solution, especially about the > heuristic (if someone has an experience on a system where the > heuristic would not work at all for example) though any suggestion / > correcting is welcome. > If I read you correctly, this has been developed before: http://www.boost.org/libs/utility/call_traits.htm Best, John -- http://John.Torjo.com -- C++ expert .... call me only if you want things done right [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: courpron on 25 Nov 2007 18:20 On 26 nov, 01:14, Mathias Gaunard <loufo...(a)gmail.com> wrote: > On 25 nov, 18:07, courp...(a)gmail.com wrote: > > > if ( sizeof(Type) > sizeof(Type*) ) > > pass by ref to const > > else > > pass by value > > This is quite naive. > The type could be small but have an expensive copy constructor. > > I suppose you only want to pass-by-value for objects with trivial copy > constructor. Yes, you guessed correctly, I'm interesting only about POD / data structures that can be copied in a raw way. I generalized too much the problem in my post and I forgot to mention that aspect. > Also, it may be interesting to pass objects sized of two words by > value too. Indeed, I thought about (sizeof(Type) > sizeof(Type)*n) where n = 2 or even 3 or 4 could work, but this is somewhat less provable than the first condition. In fact I would want to always have an equal or superior performance over just a pass by value, or just a reference to const. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: wijnand on 25 Nov 2007 19:42 Hi Alexandre, courp...(a)gmail.com wrote: > I'm seeking comments about this solution, especially about the > heuristic (if someone has an experience on a system where the > heuristic would not work at all for example) though any suggestion / > correcting is welcome. > There is already a Boost library trying to solve this: http://www.boost.org/libs/utility/call_traits.htm kind regards, Wijnand -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: Deletion of objects whose reference is holded in static map instances Next: auto_ptr definition |