diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2018-01-08 19:18:00 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2018-01-08 19:18:00 +0000 |
commit | d835e59211883ff1f55d6e89a3e7a4f49eb17e30 (patch) | |
tree | 07a42b861c0eecd3a390b55af324c63c71d83d9e /libcxx/test/std/algorithms/alg.nonmodifying | |
parent | 8ede819858cd7e9b40c84ad85d8a07556ccc0a3e (diff) | |
download | bcm5719-llvm-d835e59211883ff1f55d6e89a3e7a4f49eb17e30.tar.gz bcm5719-llvm-d835e59211883ff1f55d6e89a3e7a4f49eb17e30.zip |
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
Diffstat (limited to 'libcxx/test/std/algorithms/alg.nonmodifying')
-rw-r--r-- | libcxx/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
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::value_type, Iter2::value_type> // Iter1 // search(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); +// +// template<class ForwardIterator, class Searcher> +// ForwardIterator search(ForwardIterator first, ForwardIterator last, +// const Searcher& searcher); // C++17 #include <algorithm> #include <cassert> #include "test_iterators.h" +int searcher_called = 0; + +struct MySearcher { + template <typename Iterator> + std::pair<Iterator, Iterator> + operator() (Iterator b, Iterator e) const + { + ++searcher_called; + return std::make_pair(b, e); + } +}; + template <class Iter1, class Iter2> void test() @@ -69,4 +85,16 @@ int main() test<random_access_iterator<const int*>, forward_iterator<const int*> >(); test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >(); test<random_access_iterator<const int*>, random_access_iterator<const int*> >(); + +#if TEST_STD_VERS > 14 +{ + typedef int * RI; + static_assert((std::is_same<RI, decltype(std::search(RI(), RI(), MySearcher()))>::value), "" ); + + RI it(nullptr); + assert(it == std::search(it, it, MySearcher())); + assert(searcher_called == 1); +} +#endif + } |