From 81416e492e738c5c4da3f387f0c337f113d965c7 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 20 Jul 2015 15:40:27 +0000 Subject: Implement the plugin-based version of std::search. There are no searchers yet; those are coming soon. llvm-svn: 242679 --- .../algorithms/alg.search/search.pass.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp (limited to 'libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp') diff --git a/libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp b/libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp new file mode 100644 index 00000000000..e27f0e43b18 --- /dev/null +++ b/libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// ForwardIterator search(ForwardIterator first, ForwardIterator last, +// const Searcher& searcher); +// +// returns searcher.operator(first, last) +// + +#include +#include + +#include "test_iterators.h" + +int searcher_called = 0; + +struct MySearcher { + template + Iterator operator() ( Iterator b, Iterator /*e*/) const + { + ++searcher_called; + return b; + } +}; + + +int main() { + typedef int * RI; + static_assert(std::is_same::value, "" ); + + RI it{nullptr}; + assert(it == std::experimental::search(it, it, MySearcher())); + assert(searcher_called == 1); +} -- cgit v1.2.3