2 //===-------------------------- functional --------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL
12 #define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
15 experimental/functional synopsis
20 namespace experimental {
21 inline namespace fundamentals_v1 {
23 // See C++14 ยง20.9.9, Function object binders
24 template <class T> constexpr bool is_bind_expression_v
25 = is_bind_expression<T>::value;
26 template <class T> constexpr int is_placeholder_v
27 = is_placeholder<T>::value;
29 // 4.2, Class template function
30 template<class> class function; // undefined
31 template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
33 template<class R, class... ArgTypes>
34 void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
36 template<class R, class... ArgTypes>
37 bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
38 template<class R, class... ArgTypes>
39 bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
40 template<class R, class... ArgTypes>
41 bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
42 template<class R, class... ArgTypes>
43 bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
46 template<class ForwardIterator, class BinaryPredicate = equal_to<>>
47 class default_searcher;
49 template<class RandomAccessIterator,
50 class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
51 class BinaryPredicate = equal_to<>>
52 class boyer_moore_searcher;
54 template<class RandomAccessIterator,
55 class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
56 class BinaryPredicate = equal_to<>>
57 class boyer_moore_horspool_searcher;
59 template<class ForwardIterator, class BinaryPredicate = equal_to<>>
60 default_searcher<ForwardIterator, BinaryPredicate>
61 make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
62 BinaryPredicate pred = BinaryPredicate());
64 template<class RandomAccessIterator,
65 class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
66 class BinaryPredicate = equal_to<>>
67 boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate>
68 make_boyer_moore_searcher(
69 RandomAccessIterator pat_first, RandomAccessIterator pat_last,
70 Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
72 template<class RandomAccessIterator,
73 class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
74 class BinaryPredicate = equal_to<>>
75 boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate>
76 make_boyer_moore_horspool_searcher(
77 RandomAccessIterator pat_first, RandomAccessIterator pat_last,
78 Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
80 } // namespace fundamentals_v1
81 } // namespace experimental
83 template<class R, class... ArgTypes, class Alloc>
84 struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
90 #include <experimental/__config>
94 #include <__undef_min_max>
98 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
99 #pragma GCC system_header
102 _LIBCPP_BEGIN_NAMESPACE_LFTS
105 template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
106 class default_searcher {
108 default_searcher(_ForwardIterator __f, _ForwardIterator __l,
109 _BinaryPredicate __p = _BinaryPredicate())
110 : __first_(__f), __last_(__l), __pred_(__p) {}
112 template <typename _ForwardIterator2>
113 _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const {
114 return _VSTD::search(__f, __l, __first_, __last_, __pred_);
118 _ForwardIterator __first_;
119 _ForwardIterator __last_;
120 _BinaryPredicate __pred_;
123 template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
124 default_searcher<_ForwardIterator, _BinaryPredicate>
125 make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
127 return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
131 _LIBCPP_END_NAMESPACE_LFTS
133 #endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */