Namespaces
Variants
Views
Actions

Talk:cpp/algorithm/rotate

From cppreference.com

[edit] Order of parameters

I'd propose to discuss the parameters in the order in which they are accepted by rotate(): first, n_first, last. Otherwise the reader may be tricked into thinking that the order of parameters would be first, last, n_first (as has happened to me). --Extensive 01:30, 25 July 2013 (PDT)

I agree that the ordering on this particular function is a little tricky, so it's worth being more explicit. I made the parameter description list match the function-call order. -Nate 07:42, 25 July 2013 (PDT)

[edit] Example

Technically, the std:: prefixes weren't needed in those lines where I didn't have them (generate_n(), copy(), etc), due to ADL. Not that I mind. --Cubbi 15:07, 17 August 2011 (PDT)

Several reasons:
  • Consistency.
  • Clearier code as it may not be instantly clear, why std:: is omitted.
  • It may break code in some circumstances, such as when the type of the argument is changed and ADL no longer applies.
  • Not usable in templates where the argument is not necessarily from std:: (or any other) namespace.
  • Probably most important: the code highlighter engine here makes links that point to the description page for most of the functions/classes, but only if std:: is prefixed. The list of the identifiers to make links for can unfortunately be updated only manually, so not all links work. A copy of the list resides [removed].
I think I can be wrong for the ADL as I'm not used to exploit it, but still, other points IMO make a strong case to have std:: everywhere.P12 01:36, 18 August 2011 (PDT)
OK, I agree, will use them. --Cubbi 06:57, 18 August 2011 (PDT)

[edit] Weird example

Why the weird example? Can't rotate() be called just once to demonstrate that it is essentially a modulo-shift and leave it at that? The example makes it look like rotate() is something you use in the process of sorting a range...

The page already says exactly what rotate() does, I believe it is instructive to show how it may be used in programming. Added a trivial call to rotate anyway. --Cubbi 04:03, 9 March 2012 (PST)
Thanks. And... I started replying and it devolved in a longer post with philosophical undertones about where the value of cppreference.com's pages lie. :) Is there a better place than here to post that?
Maybe in Talk:cpp? This seems the best place for general discussions. -P12 16:02, 9 March 2012 (PST)