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).first 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 std::pair<Iterator, Iterator> 31 operator() (Iterator b, Iterator e) const 32 { 33 ++searcher_called; 34 return std::make_pair(b, e); 35 } 36 }; 37 38 39 int main() { 40 typedef int * RI; 41 static_assert((std::is_same<RI, decltype(std::experimental::search(RI(), RI(), MySearcher()))>::value), "" ); 42 43 RI it(nullptr); 44 assert(it == std::experimental::search(it, it, MySearcher())); 45 assert(searcher_called == 1); 46 } 47