diff --git a/libcxx/include/functional b/libcxx/include/functional --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -2967,14 +2967,14 @@ forward_iterator_tag, forward_iterator_tag) { if (__first2 == __last2) - return make_pair(__first1, __first1); // Everything matches an empty sequence + return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence while (true) { // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks while (true) { if (__first1 == __last1) // return __last1 if no element matches *__first2 - return make_pair(__last1, __last1); + return _VSTD::make_pair(__last1, __last1); if (__pred(*__first1, *__first2)) break; ++__first1; @@ -2985,9 +2985,9 @@ while (true) { if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) - return make_pair(__first1, __m1); + return _VSTD::make_pair(__first1, __m1); if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found - return make_pair(__last1, __last1); + return _VSTD::make_pair(__last1, __last1); if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 { ++__first1; @@ -3009,10 +3009,10 @@ // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern const _D2 __len2 = __last2 - __first2; if (__len2 == 0) - return make_pair(__first1, __first1); + return _VSTD::make_pair(__first1, __first1); const _D1 __len1 = __last1 - __first1; if (__len1 < __len2) - return make_pair(__last1, __last1); + return _VSTD::make_pair(__last1, __last1); const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here while (true) @@ -3020,7 +3020,7 @@ while (true) { if (__first1 == __s) - return make_pair(__last1, __last1); + return _VSTD::make_pair(__last1, __last1); if (__pred(*__first1, *__first2)) break; ++__first1; @@ -3031,7 +3031,7 @@ while (true) { if (++__m2 == __last2) - return make_pair(__first1, __first1 + __len2); + return _VSTD::make_pair(__first1, __first1 + __len2); ++__m1; // no need to check range on __m1 because __s guarantees we have enough source if (!__pred(*__m1, *__m2)) { diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp @@ -56,11 +56,24 @@ } }; -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia)) == Iter1(ia)); assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1)) == Iter1(ia)); @@ -74,38 +87,48 @@ assert(std::search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa)) == Iter1(ia)); assert(std::search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+sa-1)); assert(std::search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa)) == Iter1(ia+1)); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1)) == Iter1(ib+1)); - int id[] = {1, 2}; + T id[] = {1, 2}; assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2)) == Iter1(ib+1)); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3)) == Iter1(ib+4)); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; assert(std::search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4)) == Iter1(ib+8)); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; assert(std::search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3)) == Iter1(ih+3)); - int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); - int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); assert(std::search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk)) == Iter1(ij+6)); } int main(int, char**) { - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); #if TEST_STD_VER > 14 { diff --git a/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp b/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp --- a/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp +++ b/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp @@ -44,11 +44,24 @@ assert(result == std::experimental::search(b1, e1, s)); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); @@ -62,37 +75,47 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - int id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); - int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); } int main(int, char**) { - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp b/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp --- a/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp +++ b/libcxx/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp @@ -56,11 +56,24 @@ assert(count_equal::count <= max_count); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -74,32 +87,42 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp @@ -45,50 +45,33 @@ assert(result == std::search(b1, e1, s)); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; - const unsigned sj = sizeof(ij)/sizeof(ij[0]); - int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; - const unsigned sk = sizeof(ik)/sizeof(ik[0]); - do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +namespace std { +template <> struct hash { + std::size_t operator()(const User::S& s) const + { + return s.x; + } +}; +} // namespace std -template +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); @@ -102,30 +85,31 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - char ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); - char ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp @@ -51,45 +51,28 @@ assert(result == std::search(b1, e1, s)); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } + explicit operator size_t() const + { + return static_cast(x); + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User -template +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -103,25 +86,26 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pred.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pred.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pred.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/hash.pred.pass.cpp @@ -64,11 +64,28 @@ assert(count_equal::count <= max_count); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } + explicit operator size_t() const + { + return static_cast(x); + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -84,62 +101,27 @@ do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } -template -void -test2() -{ - char ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} - int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/pred.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/pred.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/pred.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bm/pred.pass.cpp @@ -58,11 +58,33 @@ assert(count_equal::count <= max_count); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +namespace std { +template <> struct hash { + std::size_t operator()(const User::S& s) const + { + return s.x; + } +}; +} // namespace std + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -78,59 +100,26 @@ do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} - -template -void -test2() -{ - char ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp @@ -45,50 +45,33 @@ assert(result == std::search(b1, e1, s)); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; - const unsigned sj = sizeof(ij)/sizeof(ij[0]); - int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; - const unsigned sk = sizeof(ik)/sizeof(ik[0]); - do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +namespace std { +template <> struct hash { + std::size_t operator()(const User::S& s) const + { + return s.x; + } +}; +} // namespace std -template +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); @@ -102,30 +85,31 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - char ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); - char ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp @@ -50,45 +50,28 @@ assert(result == std::search(b1, e1, s)); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } + explicit operator size_t() const + { + return static_cast(x); + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User -template +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -102,25 +85,26 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp @@ -63,45 +63,28 @@ assert(count_equal::count <= max_count); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } + explicit operator size_t() const + { + return static_cast(x); + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User -template +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -115,25 +98,26 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp @@ -57,45 +57,33 @@ assert(count_equal::count <= max_count); } -template -void -test() -{ - int ia[] = {0, 1, 2, 3, 4, 5}; - const unsigned sa = sizeof(ia)/sizeof(ia[0]); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); - do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); - do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); - do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); - do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; - do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; - const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; - do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); -} +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User -template +namespace std { +template <> struct hash { + std::size_t operator()(const User::S& s) const + { + return s.x; + } +}; +} // namespace std + +template void -test2() +test() { - char ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -109,25 +97,26 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - char ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - char id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - char ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - char ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - char ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, random_access_iterator >(); - test2, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp @@ -44,11 +44,24 @@ assert(result == std::search(b1, e1, s)); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); @@ -62,37 +75,47 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); - int id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); - int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); - int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + T ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); } int main(int, char**) { - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); return 0; } diff --git a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp --- a/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp @@ -56,11 +56,24 @@ assert(count_equal::count <= max_count); } -template +namespace User { +struct S { + S(int x) : x(x) {} + int x; + bool operator==(S other) const + { + return x == other.x; + } +}; +template +void make_pair(T&&, U&&) {} +} // namespace User + +template void test() { - int ia[] = {0, 1, 2, 3, 4, 5}; + T ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); @@ -74,32 +87,42 @@ do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); - int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + T ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); - int ic[] = {1}; + T ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); - int id[] = {1, 2}; + T id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); - int ie[] = {1, 2, 3}; + T ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); - int ig[] = {1, 2, 3, 4}; + T ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); - int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + T ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); - int ii[] = {1, 1, 2}; + T ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); } int main(int, char**) { - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); - test, forward_iterator >(); - test, bidirectional_iterator >(); - test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); return 0; }