@@ -421,6 +421,16 @@ void swap(some_struct &lhs, some_struct &rhs) {
421421 rhs.swap_val = " rhs" ;
422422}
423423
424+ struct List {
425+ std::list<int > data;
426+ };
427+
428+ std::list<int >::const_iterator begin (const List &list) {
429+ return list.data .begin ();
430+ }
431+
432+ std::list<int >::const_iterator end (const List &list) { return list.data .end (); }
433+
424434struct requires_move {};
425435int *begin (requires_move &&) { return nullptr ; }
426436int *end (requires_move &&) { return nullptr ; }
@@ -961,6 +971,13 @@ TEST(STLExtrasTest, hasNItems) {
961971 EXPECT_TRUE (hasNItems (V3.begin (), V3.end (), 3 , [](int x) { return x < 10 ; }));
962972 EXPECT_TRUE (hasNItems (V3.begin (), V3.end (), 0 , [](int x) { return x > 10 ; }));
963973 EXPECT_TRUE (hasNItems (V3.begin (), V3.end (), 2 , [](int x) { return x < 5 ; }));
974+
975+ // Make sure that we use the `begin`/`end` functions from `some_namespace`,
976+ // using ADL.
977+ some_namespace::List L;
978+ L.data = {0 , 1 , 2 };
979+ EXPECT_FALSE (hasNItems (L, 2 ));
980+ EXPECT_TRUE (hasNItems (L, 3 ));
964981}
965982
966983TEST (STLExtras, hasNItemsOrMore) {
@@ -983,6 +1000,13 @@ TEST(STLExtras, hasNItemsOrMore) {
9831000 hasNItemsOrMore (V3.begin (), V3.end (), 3 , [](int x) { return x > 10 ; }));
9841001 EXPECT_TRUE (
9851002 hasNItemsOrMore (V3.begin (), V3.end (), 2 , [](int x) { return x < 5 ; }));
1003+
1004+ // Make sure that we use the `begin`/`end` functions from `some_namespace`,
1005+ // using ADL.
1006+ some_namespace::List L;
1007+ L.data = {0 , 1 , 2 };
1008+ EXPECT_TRUE (hasNItemsOrMore (L, 1 ));
1009+ EXPECT_FALSE (hasNItems (L, 4 ));
9861010}
9871011
9881012TEST (STLExtras, hasNItemsOrLess) {
@@ -1016,6 +1040,13 @@ TEST(STLExtras, hasNItemsOrLess) {
10161040 hasNItemsOrLess (V3.begin (), V3.end (), 5 , [](int x) { return x < 5 ; }));
10171041 EXPECT_FALSE (
10181042 hasNItemsOrLess (V3.begin (), V3.end (), 2 , [](int x) { return x < 10 ; }));
1043+
1044+ // Make sure that we use the `begin`/`end` functions from `some_namespace`,
1045+ // using ADL.
1046+ some_namespace::List L;
1047+ L.data = {0 , 1 , 2 };
1048+ EXPECT_FALSE (hasNItemsOrLess (L, 1 ));
1049+ EXPECT_TRUE (hasNItemsOrLess (L, 4 ));
10191050}
10201051
10211052TEST (STLExtras, MoveRange) {
0 commit comments