Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: sorting cri...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 9575 of 9831
Post > Topic >>

Re: sorting criteria (understanding)

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! ]
 




 2 Posts in Topic:
sorting criteria (understanding)
Thomas Lehmann <t.lehm  2008-05-07 11:43:27 
Re: sorting criteria (understanding)
Maciej Sobczak <see.my  2008-05-07 18:33:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 3:06:50 CDT 2008.