<div dir="ltr">Maybe - I'm not sure the explicit ctor is sufficiently explicit from a self-documenting code perspective:<br><br>reverse_iterator R(I);<br>reverse_iterator R = I.getReverse();<br><br>I would be a bit surprised that those two things had different semantics.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 30, 2017 at 9:47 AM Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think adding:<br class="gmail_msg">
--<br class="gmail_msg">
explicit iterator(reverse_iterator I) : I(++I.getReverse().base()) {}<br class="gmail_msg">
explicit reverse_iterator(iterator I) : I(++I.getReverse().base()) {}<br class="gmail_msg">
--<br class="gmail_msg">
should fix the problem.<br class="gmail_msg">
- getReverse() keeps the current semantics of getting the reverse of whatever you're currently referencing.<br class="gmail_msg">
- conversions between forward/reverse do the same thing as std::reverse_iterator, with the off-by-1 thing.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
> On 2017-Jan-30, at 09:43, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> Yeah, I think it might be too subtle to have these reverse iterators behave differently from other reverse iterators. (I haven't checked the spec in detail to see if it's only stD::reverse_iterator that has this oddity, or if all reverse iterators must do so) 'getReverse' seems like a good/clear solution, if a little odd but at least visibly so.<br class="gmail_msg">
><br class="gmail_msg">
> On Wed, Jan 25, 2017 at 3:33 PM Matthias Braun via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg">
> MatzeB abandoned this revision.<br class="gmail_msg">
> MatzeB added a comment.<br class="gmail_msg">
><br class="gmail_msg">
> I wasn't aware of the subtle shift-by-1 semantics when converting to std::reverse_iterator (must have missed the getReverse() comment). If we go with that semantics I would need extra std::next/std::prev calls in my code anyway which doesn't make it much simpler compared to MyIterator->getReverseIterator(). Going for semantics different from STL is not a good idea IMO.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Repository:<br class="gmail_msg">
> rL LLVM<br class="gmail_msg">
><br class="gmail_msg">
> <a href="https://reviews.llvm.org/D27874" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D27874</a><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> llvm-commits mailing list<br class="gmail_msg">
> <a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>