POV-Ray : Newsgroups : povray.off-topic : An explanation of what next_permutation does : Re: An explanation of what next_permutation does Server Time
4 Sep 2024 23:23:09 EDT (-0400)
  Re: An explanation of what next_permutation does  
From: Warp
Date: 7 Dec 2009 12:48:48
Message: <4b1d4000@news.povray.org>
scott <sco### [at] scottcom> wrote:
> > And in why is it 'not (x < y)" rather than 'x >= y'?"

> Aren't they the same? (btw the only reason I can see that you would use the 
> first one is if the types being used don't have the >= operator defined). 
> IIRC quite a lot of functions and libraries only assume that one of those 
> operators is implemented, so that's probably why you'll see stuff like that.

  It is customary in the C++ standard library to demand as little as
possible from the types being handled. Anything requiring comparison of
element usually demands only operator< from the elements (if the algorithm
can be feasibly be implemented using that operator only).

  If you are making a generic algorithm or data container which compares
elements, it's also usually a good idea to demand as little as possible
from it, and stick to operator< exclusively, if possible.

-- 
                                                          - Warp


Post a reply to this message

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