llvm.org GIT mirror llvm / b1a1e51
Use std::iterator_traits to infer result type of llvm::enumerate iterator wrapper Update the llvm::enumerate helper class result_pair<R> to use the 'iterator_traits<R>::reference' type as the result of 'value()' instead 'ValueOfRange<R> &'. This enables support for iterators that return value types, i.e. non reference. This is a common pattern for some classes of iterators, e.g. mapped_iterator. Patch by: River Riddle <riverriddle@google.com> Differential Revision: https://reviews.llvm.org/D63632 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364007 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 1 year, 3 months ago
1 changed file(s) with 5 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
15051505 template class enumerator_iter;
15061506
15071507 template struct result_pair {
1508 using value_reference =
1509 typename std::iterator_traits>::reference;
1510
15081511 friend class enumerator_iter;
15091512
15101513 result_pair() = default;
15181521 }
15191522
15201523 std::size_t index() const { return Index; }
1521 const ValueOfRange &value() const { return *Iter; }
1522 ValueOfRange &value() { return *Iter; }
1524 const value_reference value() const { return *Iter; }
1525 value_reference value() { return *Iter; }
15231526
15241527 private:
15251528 std::size_t Index = std::numeric_limits::max();