From d835e59211883ff1f55d6e89a3e7a4f49eb17e30 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 8 Jan 2018 19:18:00 +0000 Subject: Add the C++17 extensions to std::search. Include the default searcher, but not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon llvm-svn: 322019 --- .../alg.nonmodifying/alg.search/search.pass.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp') 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 index e5c2dd29d11..601bc6f0012 100644 --- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp +++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp @@ -13,12 +13,28 @@ // requires HasEqualTo // Iter1 // search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); +// +// template +// ForwardIterator search(ForwardIterator first, ForwardIterator last, +// const Searcher& searcher); // C++17 #include #include #include "test_iterators.h" +int searcher_called = 0; + +struct MySearcher { + template + std::pair + operator() (Iterator b, Iterator e) const + { + ++searcher_called; + return std::make_pair(b, e); + } +}; + template void test() @@ -69,4 +85,16 @@ int main() test, forward_iterator >(); test, bidirectional_iterator >(); test, random_access_iterator >(); + +#if TEST_STD_VERS > 14 +{ + typedef int * RI; + static_assert((std::is_same::value), "" ); + + RI it(nullptr); + assert(it == std::search(it, it, MySearcher())); + assert(searcher_called == 1); +} +#endif + } -- cgit v1.2.3