POV-Ray : Newsgroups : povray.off-topic : new C# stuff : Re: new C# stuff Server Time
6 Sep 2024 15:19:27 EDT (-0400)
  Re: new C# stuff  
From: Darren New
Date: 24 Jan 2009 13:36:37
Message: <497b5fb5$1@news.povray.org>
Nicolas Alvarez wrote:
> Darren New wrote:
>> In C++ you call
>>    qsort(myArray, operator< );
>> or some such syntax, but without the need to have a specifically named
>> function just to wrap up the < operator.
> 
> std::sort(myArray) is all you need. Guess *how* the operator< is used by
> default?
> 
> template <typename T> bool less(const T& x, const T& y) {
>     return x < y;
> }
> 
> std::sort uses std::less as the default sorting function.
> 

Yep. And now what do you do if the "less" you want to use is actually a 
member function of type T?  What if the "less" you want to use is
class MyDate {
   bool comesBefore(const MyDate& otherDate);
}

-- 
   Darren New, San Diego CA, USA (PST)
   "Ouch ouch ouch!"
   "What's wrong? Noodles too hot?"
   "No, I have Chopstick Tunnel Syndrome."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.