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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@322019 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2018-01-08 19:18:00 +00:00
parent 4b1bc157d4
commit 334063336b
14 changed files with 1414 additions and 82 deletions

View File

@@ -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
}