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

Jordan Rose via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 11:41:09 PDT 2018


jordan_rose added a comment.

> 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.


Repository:
  rL LLVM

https://reviews.llvm.org/D45140





More information about the llvm-commits mailing list