<div dir="ltr">Usually member variables that can be non-instance members should be non-instance members so as to allow equal conversions on the left and right hand operands. One way to do this is to declare it as a friend, instead of as a non-static member (or even define it in terms of another operation)<br><br>Also not sure whether that operation should be out of line, or just make it inline?</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 29, 2016 at 9:48 AM, Filipe Cabecinhas via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: filcab<br>
Date: Fri Apr 29 11:48:07 2016<br>
New Revision: 268062<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268062&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=268062&view=rev</a><br>
Log:<br>
Add operator- to Path's reverse_iterator. Needed for D19666<br>
<br>
Reviewers: rafael, craig.topper, bogner<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D19724" rel="noreferrer" target="_blank">http://reviews.llvm.org/D19724</a><br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Support/Path.h<br>
llvm/trunk/lib/Support/Path.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Support/Path.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Path.h?rev=268062&r1=268061&r2=268062&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Path.h?rev=268062&r1=268061&r2=268062&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/Path.h (original)<br>
+++ llvm/trunk/include/llvm/Support/Path.h Fri Apr 29 11:48:07 2016<br>
@@ -87,6 +87,9 @@ public:<br>
reverse_iterator &operator++(); // preincrement<br>
bool operator==(const reverse_iterator &RHS) const;<br>
bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }<br>
+<br>
+ /// @brief Difference in bytes between this and RHS.<br>
+ ptrdiff_t operator-(const reverse_iterator &RHS) const;<br>
};<br>
<br>
/// @brief Get begin iterator over \a path.<br>
<br>
Modified: llvm/trunk/lib/Support/Path.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=268062&r1=268061&r2=268062&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=268062&r1=268061&r2=268062&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Support/Path.cpp (original)<br>
+++ llvm/trunk/lib/Support/Path.cpp Fri Apr 29 11:48:07 2016<br>
@@ -353,6 +353,10 @@ bool reverse_iterator::operator==(const<br>
Position == RHS.Position;<br>
}<br>
<br>
+ptrdiff_t reverse_iterator::operator-(const reverse_iterator &RHS) const {<br>
+ return Position - RHS.Position;<br>
+}<br>
+<br>
StringRef root_path(StringRef path) {<br>
const_iterator b = begin(path),<br>
pos = b,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>