[PATCH] D53447: [adt] SparseBitVector::test() should be const

Roman Tereshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 31 10:34:49 PDT 2018


rtereshin accepted this revision.
rtereshin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for doing this!



================
Comment at: include/llvm/ADT/SparseBitVector.h:310
   }
+  ElementListConstIter FindLowerBoundConst(unsigned ElementIndex) const {
+    return FindLowerBoundImpl(ElementIndex);
----------------
Technically, `const` qualifier is a part of the member function signature, so no need for a different name. If called from another  const function, like `test`, the const version of this function will be called regardless of the object itself being const or not.

But honestly, I like making the difference explicit in this specific case, it draws attention, and it's probably a good thing as `FindLowerBoundImpl` needs to be used or modified with care so we don't accidentally leak a non-const iterator from a const object in the future.

In the end, I'm fine with both, a different name and the same.


Repository:
  rL LLVM

https://reviews.llvm.org/D53447





More information about the llvm-commits mailing list