[PATCH] D97921: [ADT][NFC] Use `size_t` type for index in `indexed_accessor_range`
Vladislav Vinogradov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 01:42:12 PST 2021
vinograd47 created this revision.
vinograd47 added a reviewer: rriddle.
Herald added subscribers: dexonsmith, arphaman.
vinograd47 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
It makes it consistent with `size()` method return type and with
STL-like containers API.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97921
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -1114,9 +1114,9 @@
iterator begin() const { return iterator(base, 0); }
iterator end() const { return iterator(base, count); }
- ReferenceT operator[](unsigned index) const {
+ ReferenceT operator[](size_t index) const {
assert(index < size() && "invalid index for value range");
- return DerivedT::dereference_iterator(base, index);
+ return DerivedT::dereference_iterator(base, static_cast<ptrdiff_t>(index));
}
ReferenceT front() const {
assert(!empty() && "expected non-empty range");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97921.328069.patch
Type: text/x-patch
Size: 709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210304/f719ce72/attachment-0001.bin>
More information about the llvm-commits
mailing list