by Maciej Sobczak <see.my.homepage@[EMAIL PROTECTED]
>
May 7, 2008 at 06:33 PM
On 7 Maj, 19:43, Thomas Lehmann <t.lehm...@[EMAIL PROTECTED]
> wrote:
> question: "Why is the functor of a std::sort copied several times?"
Better: Why not?
It is not guaranteed that the functor will be copied several times,
but your responsibility is to ensure that it is OK to actually do so.
This gives more freedom for implementers of the sort algorithm. Note
also that function pointer is a possible comparator - the sort
algorithm might be written with the assumption that whatever it can do
with the function pointer is also good for any other comparator type.
Try not to work against this assumption and prefer lightweight
comparators if possible.
Of course, "every computing problem can be solved with additional
level of indirection" - this is what your adapter does.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]