Implement the plugin-based version of std::search. There are no searchers yet; those are coming soon.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242679 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fd9bbf52cd
commit
166dadbcbe
@ -50,6 +50,12 @@ SampleIterator sample(PopulationIterator first, PopulationIterator last,
|
|||||||
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
_LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||||
|
|
||||||
|
|
||||||
|
template <class _ForwardIterator, class _Searcher>
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
|
||||||
|
{ return __s(__f, __l); }
|
||||||
|
|
||||||
|
|
||||||
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
template <class _PopulationIterator, class _SampleIterator, class _Distance,
|
||||||
class _UniformRandomNumberGenerator>
|
class _UniformRandomNumberGenerator>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
43
test/std/experimental/algorithms/alg.search/search.pass.cpp
Normal file
43
test/std/experimental/algorithms/alg.search/search.pass.cpp
Normal file
@ -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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user