From: Vladimir Grigoriev on 20 Jan 2010 11:31 "Stephan T. Lavavej [MSFT]" <stl(a)microsoft.com> wrote in message news:el5it1jlKHA.3128(a)TK2MSFTNGP02.phx.gbl... >> Ah, but Vladimir _wants_ it to return y for #2. > > Then Anti-Vladimir would complain that #2 should return x, because > returning the first of two equivalent arguments is the natural choice. > It's "stable" in the sense of stable_sort(), which preserves the relative > order of equivalent elements. I do not see here any problem. He may use the min as he are going to use it. What is the problem? > > The Standard's opinion is that Anti-Vladimir has the more powerful > argument. sort() had to choose between accepting std::less-like and > std::less_equal-like predicates (because it has to know when elements are > equivalent, and my previous reply explained why determining equivalency > without knowing whether the predicate is std::less-like or > std::less_equal-like without compromising performance is impossible). It > chose std::less due to simplicity. Therefore, requiring std::less-like > predicates for min/max is very simple to explain, and unsurprising once > you've learned sort()'s convention. Does sort uses the min algorithm? And one more it is your choice how you are going to sort your sequence. Nobody to fource you to use the less_equal predicate? Bu its using gives new opportunities. Vladimir Grigoriev
From: Ulrich Eckhardt on 21 Jan 2010 03:25 Vladimir Grigoriev top-posted: > Sorry, I have not seen why I can not use the less_equal for min. ....because the standard says that it requires a strict-weak ordering as predicate? > If I use the less_equal I do that intestinally for example to get the > second argument in the case of arguments equality. The standard allows use of greater for max, maybe that could help you achieve what you want in a conforming way? > No annotation in the Standard is required. It is enough that the min > may use a predicate. It a user choice which predicate to use in his > code. So what? You say the standard imposes requirements that aren't actually necessary. File a defect report with the C++ standards committee then, but don't say implementations should support your code that is - according to the standard - broken. I don't understand why this issue is still being discussed here, all points above (except perhaps the greater/max suggestion) were already mentioned here. Uli [TOFU removed] -- C++ FAQ: http://parashift.com/c++-faq-lite Sator Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
From: Vladimir Grigoriev on 21 Jan 2010 05:29 Thanks, Ulrich. I know already what the Standard says relative the std::min, however I do not see any reasonable explanation of why it says so. Vladimir Grigoriev "Ulrich Eckhardt" <eckhardt(a)satorlaser.com> wrote in message news:akfl27-rsa.ln1(a)satorlaser.homedns.org... > Vladimir Grigoriev top-posted: >> Sorry, I have not seen why I can not use the less_equal for min. > > ...because the standard says that it requires a strict-weak ordering as > predicate? > >> If I use the less_equal I do that intestinally for example to get the >> second argument in the case of arguments equality. > > The standard allows use of greater for max, maybe that could help you > achieve what you want in a conforming way? > >> No annotation in the Standard is required. It is enough that the min >> may use a predicate. It a user choice which predicate to use in his >> code. > > So what? You say the standard imposes requirements that aren't actually > necessary. File a defect report with the C++ standards committee then, but > don't say implementations should support your code that is - according to > the standard - broken. > > I don't understand why this issue is still being discussed here, all > points > above (except perhaps the greater/max suggestion) were already mentioned > here. > > Uli > > [TOFU removed] > > -- > C++ FAQ: http://parashift.com/c++-faq-lite > > Sator Laser GmbH > Geschaftsfuhrer: Thorsten Focking, Amtsgericht Hamburg HR B62 932
First
|
Prev
|
Pages: 1 2 3 4 5 Prev: volatile keyword and memory barriers Next: Can not deduse template arguments std::rel_ops |