<div dir="ltr">I'm good with it - don't much mind whether it's reviewed separately or not myself, so long as the commit messages, etc, are accurate of the final form. I'd only suggest modifying the test somewhat - rather than testing that array_lengthof is the same as size, I'd test that the size answers are correct in absolute terms (ie: by hardcoding the answer: EXPECT_EQ(3, size(a1)); etc... <div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 30, 2018 at 1:25 AM James Henderson <<a href="mailto:jh7370.2008@my.bristol.ac.uk">jh7370.2008@my.bristol.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I think this would be worthwhile, personally. I'd create a separate review for it though, mentioning the original.</div></div><div dir="ltr"><div><br></div><div>James<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 July 2018 at 01:46, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Neat! That seems to work:<div><br></div><div>```</div><div><div>diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h</div><div>index 94365dd9ced..47450623826 100644</div><div>--- a/llvm/include/llvm/ADT/STLExtras.h</div><div>+++ b/llvm/include/llvm/ADT/STLExtras.h</div><div>@@ -1044,11 +1044,11 @@ void erase_if(Container &C, UnaryPredicate P) {</div><div> template <typename R></div><div> auto size(R &&Range, typename std::enable_if<</div><div>                          std::is_same<typename std::iterator_traits<decltype(</div><div>-                                          Range.begin())>::iterator_category,</div><div>+                                          adl_begin(Range))>::iterator_category,</div><div>                                       std::random_access_iterator_tag>::value,</div><div>                          void>::type * = nullptr)</div><div>-    -> decltype(std::distance(Range.begin(), Range.end())) {</div><div>-  return std::distance(Range.begin(), Range.end());</div><div>+    -> decltype(std::distance(adl_begin(Range), adl_end(Range))) {</div><div>+  return std::distance(adl_begin(Range), adl_end(Range));</div><div> }</div><div> </div><div> //===----------------------------------------------------------------------===//</div><div>diff --git a/llvm/unittests/ADT/IteratorTest.cpp b/llvm/unittests/ADT/IteratorTest.cpp</div><div>index 50c3b01bbc7..b335bdec766 100644</div><div>--- a/llvm/unittests/ADT/IteratorTest.cpp</div><div>+++ b/llvm/unittests/ADT/IteratorTest.cpp</div><div>@@ -382,9 +382,13 @@ TEST(ZipIteratorTest, Reverse) {</div><div> TEST(RangeTest, Distance) {</div><div>   std::vector<int> v1;</div><div>   std::vector<int> v2{1, 2, 3};</div><div>+  int a1[] = {1, 2, 3};</div><div>+  int a2[5] = {0};</div><div> </div><div>   EXPECT_EQ(std::distance(v1.begin(), v1.end()), size(v1));</div><div>   EXPECT_EQ(std::distance(v2.begin(), v2.end()), size(v2));</div><div>+  EXPECT_EQ(array_lengthof(a1), size(a1));</div><div>+  EXPECT_EQ(array_lengthof(a2), size(a2));</div><div> }</div><div> </div><div> TEST(IteratorRangeTest, DropBegin) {</div><div>```</div><div><br></div><div>Do folks think this is worth supporting?</div><span class="m_-7782826356138671035HOEnZb"><font color="#888888"><div><br></div><div>vedant</div></font></span><div><div class="m_-7782826356138671035h5"><div><div><br><blockquote type="cite"><div>On Jul 23, 2018, at 4:23 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_-7782826356138671035m_-5691652884765032467Apple-interchange-newline"><div><div dir="ltr">Seems like the existing size(R &&Range) function could be generalized (by using adl_begin/end rather than member begin/end? Would that be enough) to cover arrays as well, maybe?</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jul 18, 2018 at 11:24 AM Paul Semel via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">paulsemel closed this revision.<br>
paulsemel added a comment.<br>
<br>
I agree with James !<br>
<br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D49402" rel="noreferrer" target="_blank">https://reviews.llvm.org/D49402</a><br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</blockquote></div>