diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2015-07-20 15:40:27 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2015-07-20 15:40:27 +0000 |
commit | 81416e492e738c5c4da3f387f0c337f113d965c7 (patch) | |
tree | ed6f9664e62b1bdb080930cae7049908542de8bd /libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp | |
parent | b5960564133b8794fc1065869b9e2d4fbf6530ea (diff) | |
download | bcm5719-llvm-81416e492e738c5c4da3f387f0c337f113d965c7.tar.gz bcm5719-llvm-81416e492e738c5c4da3f387f0c337f113d965c7.zip |
Implement the plugin-based version of std::search. There are no searchers yet; those are coming soon.
llvm-svn: 242679
Diffstat (limited to 'libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp')
-rw-r--r-- | libcxx/test/std/experimental/algorithms/alg.search/search.pass.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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. +// +//===----------------------------------------------------------------------===// + +// <algorithm> + +// template<class ForwardIterator, class Searcher> +// ForwardIterator search(ForwardIterator first, ForwardIterator last, +// const Searcher& searcher); +// +// returns searcher.operator(first, last) +// + +#include <experimental/algorithm> +#include <cassert> + +#include "test_iterators.h" + +int searcher_called = 0; + +struct MySearcher { + template <typename Iterator> + Iterator operator() ( Iterator b, Iterator /*e*/) const + { + ++searcher_called; + return b; + } +}; + + +int main() { + typedef int * RI; + static_assert(std::is_same<RI, decltype(std::experimental::search(RI(), RI(), MySearcher()))>::value, "" ); + + RI it{nullptr}; + assert(it == std::experimental::search(it, it, MySearcher())); + assert(searcher_called == 1); +} |