1166dadbcbeca7966cd2517972b670834295184dfMarshall Clow//===----------------------------------------------------------------------===// 2166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// 3166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// The LLVM Compiler Infrastructure 4166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// 5166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// This file is dual licensed under the MIT and the University of Illinois Open 6166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// Source Licenses. See LICENSE.TXT for details. 7166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// 8166dadbcbeca7966cd2517972b670834295184dfMarshall Clow//===----------------------------------------------------------------------===// 9166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 10166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// <algorithm> 11166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 12166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// template<class ForwardIterator, class Searcher> 13166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// ForwardIterator search(ForwardIterator first, ForwardIterator last, 14166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// const Searcher& searcher); 15166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// 16166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// returns searcher.operator(first, last) 17166dadbcbeca7966cd2517972b670834295184dfMarshall Clow// 18166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 19166dadbcbeca7966cd2517972b670834295184dfMarshall Clow#include <experimental/algorithm> 20166dadbcbeca7966cd2517972b670834295184dfMarshall Clow#include <cassert> 21166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 22166dadbcbeca7966cd2517972b670834295184dfMarshall Clow#include "test_iterators.h" 23166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 24166dadbcbeca7966cd2517972b670834295184dfMarshall Clowint searcher_called = 0; 25166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 26166dadbcbeca7966cd2517972b670834295184dfMarshall Clowstruct MySearcher { 27166dadbcbeca7966cd2517972b670834295184dfMarshall Clow template <typename Iterator> 28166dadbcbeca7966cd2517972b670834295184dfMarshall Clow Iterator operator() ( Iterator b, Iterator /*e*/) const 29166dadbcbeca7966cd2517972b670834295184dfMarshall Clow { 30166dadbcbeca7966cd2517972b670834295184dfMarshall Clow ++searcher_called; 31166dadbcbeca7966cd2517972b670834295184dfMarshall Clow return b; 32166dadbcbeca7966cd2517972b670834295184dfMarshall Clow } 33166dadbcbeca7966cd2517972b670834295184dfMarshall Clow}; 34166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 35166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 36166dadbcbeca7966cd2517972b670834295184dfMarshall Clowint main() { 37166dadbcbeca7966cd2517972b670834295184dfMarshall Clow typedef int * RI; 38166dadbcbeca7966cd2517972b670834295184dfMarshall Clow static_assert(std::is_same<RI, decltype(std::experimental::search(RI(), RI(), MySearcher()))>::value, "" ); 39166dadbcbeca7966cd2517972b670834295184dfMarshall Clow 40166dadbcbeca7966cd2517972b670834295184dfMarshall Clow RI it{nullptr}; 41166dadbcbeca7966cd2517972b670834295184dfMarshall Clow assert(it == std::experimental::search(it, it, MySearcher())); 42166dadbcbeca7966cd2517972b670834295184dfMarshall Clow assert(searcher_called == 1); 43166dadbcbeca7966cd2517972b670834295184dfMarshall Clow} 44