1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11
11 
12 // <algorithm>
13 
14 //   template<class ForwardIterator, class Searcher>
15 //   ForwardIterator search(ForwardIterator first, ForwardIterator last,
16 //                          const Searcher& searcher);
17 //
18 //		returns searcher.operator(first, last)
19 //
20 
21 #include <experimental/algorithm>
22 #include <cassert>
23 
24 #include "test_iterators.h"
25 
26 int searcher_called = 0;
27 
28 struct MySearcher {
29     template <typename Iterator>
30     Iterator operator() ( Iterator b, Iterator /*e*/) const
31     {
32         ++searcher_called;
33         return b;
34     }
35 };
36 
37 
38 int main() {
39     typedef int * RI;
40     static_assert((std::is_same<RI, decltype(std::experimental::search(RI(), RI(), MySearcher()))>::value), "" );
41 
42     RI it(nullptr);
43     assert(it == std::experimental::search(it, it, MySearcher()));
44     assert(searcher_called == 1);
45 }
46