<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 29, 2015, at 2:44 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Drop the ", int" from enable_if and use nullptr instead of 0 for the default value (enable_if uses void* by default, so this is sort of more typical - of course the 0 works too)<br class=""><br class="">Perhaps add:<br class=""><br class=""><div class="">  const TypeParam c = {0, 1, 2, 3};</div><div class="">  TestRev(reverse(c));<br class=""><br class="">to TYPED_TEST(RangeAdapterLValueTest, TrivialOperation), to test the const cases?<br class=""></div></div></div></blockquote>Done.  I remove the custom vector types from the lvalue test as they don’t support const_iterator’s.  But they are tested in the rvalue test so that should be fine.<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class="">& run the whole thing through clang-format, if you haven't already? (I see some inconsistencies - like the space, or not, between the {} for the two Test derived class templates)<br class=""></div></div></div></blockquote>Yeo, there were a few missing places.  I went over the changes made by clang format and all looked fine.</div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class="">& then feel free to commit at your leisure & we'll cross our fingers for the GCC bots.</div></div></div></blockquote>Great.  Thanks again for all the help.  I get the feeling as this point that you could have written it faster than helping me, so i really appreciate the guidance on this.  Its r243581.</div><div><br class=""></div><div>Pete<br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jul 29, 2015 at 2:38 PM, Pete Cooper <span dir="ltr" class=""><<a href="mailto:peter_cooper@apple.com" target="_blank" class="">peter_cooper@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2015, at 2:22 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><br class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">On Wed, Jul 29, 2015 at 2:02 PM, Pete Cooper<span class=""> </span></span><span dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><<a href="mailto:peter_cooper@apple.com" target="_blank" class="">peter_cooper@apple.com</a>></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class=""><span class=""> </span></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jul 29, 2015, at 1:50 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank" class="">dblaikie@gmail.com</a>> wrote:</div><br class=""><div class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">Yep, something like that looks about right. I'm not sure if it can be generalized further so we can reuse some of the machinery for begin, end, rbegin, rend, getDecl, etc. You can probably just SFINAE on begin/rbegin and assume end/rend exist - but if we can get the SFINAE tidy enough it wouldn't hurt to test for both, I suppose.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">btw, my change to the test that demonstrates the problem with using universal ref/lvalue ref distinction to differentiate is this: add "const ReverseOnlyVector/const BidirectionalVector" to the Types vector & you'll see failures in the existing implementation. Alternatively/in addition, could refactor out the body of the TrivialOperation test into a template, then instantiate that template with TypeParam and const TypeParam, so you don't have to list all of them as const/non-const in the list of types.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">Also, I added this rvalue version:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">template <typename T> struct RangeAdapterRValueTest : testing::Test {};</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">typedef ::testing::Types<std::vector<int>, std::list<int>, ReverseOnlyVector,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">                         BidirectionalVector> RangeAdapterRValueTestTypes;</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">TYPED_TEST_CASE(RangeAdapterRValueTest, RangeAdapterRValueTestTypes);</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">template<typename R></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">void TestRev(const R& r) {</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""> <span class=""> </span>int counter = 3;</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""> <span class=""> </span>for (int i : r)</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">   <span class=""> </span>EXPECT_EQ(i, counter--);</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">}</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">TYPED_TEST(RangeAdapterRValueTest, TrivialOperation) {</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""> <span class=""> </span>TestRev(reverse(TypeParam({0, 1, 2, 3})));</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">}</div></div></blockquote></span>Very nice.  Thanks for doing that.</div><div class=""><br class=""></div><div class="">Here’s a patch with the fixes.  I had to extend has_rbegin to handle whether its a class or not (int[] failed without that).  Otherwise its basically just like has_getDecl.  I think has_getDecl is in an internal namespace.  I can do the same here if you like, i’m fine either way.</div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class="">So the rvalue tests I added don't cover the non-rvalue case your existing test cases covered (nor the array cases) - looks like you dropped the originals?<br class=""></div></div></blockquote></span>Sorry, i misread your email before.  I thought what you had replaced my tests, now I see that it was the additional of rvalue tests.  I’ve refactored what I had to use the TestRev method you have and added lvalue tests.<span class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class="">I wonder if the SFINAE can be done without trying to derive from the type (some types might not be derivable)<br class=""><br class="">Maybe the hasDecl was written pre-C++11?<br class=""><br class="">This /seems/ to work in the basic case:<br class=""><br class=""><div class="">struct foo {</div><div class="">  void func();</div><div class="">};</div><div class=""><br class=""></div><div class="">struct bar {</div><div class="">};</div><div class=""><br class=""></div><div class="">template<typename T></div><div class="">struct has_func {</div><div class="">  template<typename U></div><div class="">  static char (&f(const U&, decltype(&U::func)))[1];</div><div class="">  static char (&f(...))[2];</div><div class="">  const static bool value = sizeof(f(std::declval<T>(), nullptr)) == 1;</div><div class="">};</div><div class=""><br class=""></div><div class="">static_assert(has_func<foo>::value, "");</div><div class="">static_assert(!has_func<bar>::value, "”);<br class=""></div></div></div></blockquote></span>Yeah, thats much better.  In fact there were a couple of cases failing with my implementation when i brought back all the tests.  This version handles everything.</div><div class=""><br class=""></div><div class=""></div></div><br class=""><div style="word-wrap:break-word" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class=""><br class="">(plus the extra non-class detection you had too)</div> </div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Pete</div></div></blockquote></div></blockquote></div><br class=""></div><br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>