@@ -22,6 +22,22 @@ using testing::ElementsAre;
2222
2323namespace {
2424
25+ namespace adl_test {
26+ struct WithFreeBeginEnd {
27+ int data[3 ] = {21 , 22 , 23 };
28+ };
29+
30+ auto begin (const WithFreeBeginEnd &X) { return std::begin (X.data ); }
31+ auto end (const WithFreeBeginEnd &X) { return std::end (X.data ); }
32+
33+ struct WithFreeRBeginREnd {
34+ int data[3 ] = {42 , 43 , 44 };
35+ };
36+
37+ auto rbegin (const WithFreeRBeginREnd &X) { return std::rbegin (X.data ); }
38+ auto rend (const WithFreeRBeginREnd &X) { return std::rend (X.data ); }
39+ } // namespace adl_test
40+
2541template <int > struct Shadow ;
2642
2743struct WeirdIter
@@ -364,6 +380,14 @@ TEST(FilterIteratorTest, ReverseFilterRange) {
364380 EXPECT_EQ ((SmallVector<int , 4 >{6 , 4 , 2 , 0 }), Actual4);
365381}
366382
383+ TEST (FilterIteratorTest, ADL) {
384+ // Make sure that we use the `begin`/`end` functions
385+ // from `adl_test`, using ADL.
386+ adl_test::WithFreeBeginEnd R;
387+ auto IsOdd = [](int N) { return N % 2 != 0 ; };
388+ EXPECT_THAT (make_filter_range (R, IsOdd), ElementsAre (21 , 23 ));
389+ }
390+
367391TEST (PointerIterator, Basic) {
368392 int A[] = {1 , 2 , 3 , 4 };
369393 pointer_iterator<int *> Begin (std::begin (A)), End (std::end (A));
@@ -395,18 +419,9 @@ TEST(PointerIterator, Range) {
395419 EXPECT_EQ (A + I++, P);
396420}
397421
398- namespace rbegin_detail {
399- struct WithFreeRBegin {
400- int data[3 ] = {42 , 43 , 44 };
401- };
402-
403- auto rbegin (const WithFreeRBegin &X) { return std::rbegin (X.data ); }
404- auto rend (const WithFreeRBegin &X) { return std::rend (X.data ); }
405- } // namespace rbegin_detail
406-
407422TEST (ReverseTest, ADL) {
408423 // Check that we can find the rbegin/rend functions via ADL.
409- rbegin_detail::WithFreeRBegin Foo;
424+ adl_test::WithFreeRBeginREnd Foo;
410425 EXPECT_THAT (reverse (Foo), ElementsAre (44 , 43 , 42 ));
411426}
412427
0 commit comments