mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 10:07:41 +08:00
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:
@@ -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
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user