[PATCH] D28371: Add missing operators for iterator_facade_base
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 10:12:55 PST 2017
zturner updated this revision to Diff 83381.
zturner added a comment.
I actually removed the `operator-`, since it was not providing any value. All other base class operators are implemented in terms of a different operator on the derived class, so that you would get a hard error if the derived operator didn't exist. It was not possible to do this with the difference operator, and so at best if you failed to implement the operator in the derived class you would get a "recursive on all paths" warning, but not an error. Since you ultimately have to implement the same operator in the derived class *anyway*, the base class operator does not seem to provide any value.
The base class `operator<` stays though as it's still needed.
https://reviews.llvm.org/D28371
Files:
llvm/include/llvm/ADT/iterator.h
Index: llvm/include/llvm/ADT/iterator.h
===================================================================
--- llvm/include/llvm/ADT/iterator.h
+++ llvm/include/llvm/ADT/iterator.h
@@ -114,6 +114,13 @@
return !static_cast<const DerivedT *>(this)->operator==(RHS);
}
+ bool operator<(const DerivedT &RHS) const {
+ static_assert(
+ IsRandomAccess,
+ "Relational operators are only defined for random access iterators.");
+ return !static_cast<const DerivedT *>(this)->operator>(RHS) &&
+ !static_cast<const DerivedT *>(this)->operator==(RHS);
+ }
bool operator>(const DerivedT &RHS) const {
static_assert(
IsRandomAccess,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28371.83381.patch
Type: text/x-patch
Size: 681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170106/85513b4a/attachment.bin>
More information about the llvm-commits
mailing list