[PATCH] D45140: [Support] Change std::sort to llvm::sort in response to r327219

Mandeep Singh Grang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 11:46:23 PDT 2018


mgrang added a comment.

In https://reviews.llvm.org/D45140#1062032, @jordan_rose wrote:

> > Exactly that's what I thought too, and llvm::sort already accepts a range (Container.begin(), Container.end()). In that case, could you please clarify what exactly do you mean by a "range-based variant" and its use cases in LLVM?
>
> Ah, sorry! A "range-based" collection algorithm means one that takes a "range" as an argument instead of a pair of iterators. The "range" is anything that has `begin` and `end` iterators. ("Container-based algorithm" might have been a better name, since usually the "range" you pass is the entire container, but "range" is already an accepted term in C++ language and library discussions.)
>
> So in this case, the call would look like this:
>
>   llvm::sort(TimersToPrint);
>
>
> You can check out the implementation of `llvm::none_of` in include/llvm/ADT/STLExtras.h <http://llvm.org/doxygen/STLExtras_8h_source.html#l00860> to see how this works. It just forwards on to the regular implementation.
>
> None of this is related to your shuffling work, by the way; it's just odd and a bit inconsistent that there's an `llvm::` algorithm that only takes iterators.


Ah, got it! Thanks a lot for your clarification. I will explore adding a range-based version of llvm::sort when I have some cycles.


Repository:
  rL LLVM

https://reviews.llvm.org/D45140





More information about the llvm-commits mailing list