1// -*- C++ -*-
2//===-------------------------- functional --------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL
12#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
13
14/*
15   experimental/functional synopsis
16
17#include <algorithm>
18
19namespace std {
20namespace experimental {
21inline namespace fundamentals_v1 {
22
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;
28
29    // 4.2, Class template function
30    template<class> class function; // undefined
31    template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
32
33    template<class R, class... ArgTypes>
34    void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
35
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;
44
45    // 4.3, Searchers
46    template<class ForwardIterator, class BinaryPredicate = equal_to<>>
47      class default_searcher;
48
49    template<class RandomAccessIterator,
50             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
51             class BinaryPredicate = equal_to<>>
52      class boyer_moore_searcher;
53
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;
58
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());
63
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());
71
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());
79
80  } // namespace fundamentals_v1
81  } // namespace experimental
82
83  template<class R, class... ArgTypes, class Alloc>
84  struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
85
86} // namespace std
87
88*/
89
90#include <experimental/__config>
91#include <functional>
92#include <algorithm>
93
94#include <__undef_min_max>
95
96#include <__debug>
97
98#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
99#pragma GCC system_header
100#endif
101
102_LIBCPP_BEGIN_NAMESPACE_LFTS
103
104// default searcher
105template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
106class default_searcher {
107public:
108    default_searcher(_ForwardIterator __f, _ForwardIterator __l,
109                       _BinaryPredicate __p = _BinaryPredicate())
110        : __first_(__f), __last_(__l), __pred_(__p) {}
111
112    template <typename _ForwardIterator2>
113    _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const {
114        return _VSTD::search(__f, __l, __first_, __last_, __pred_);
115        }
116
117private:
118    _ForwardIterator __first_;
119    _ForwardIterator __last_;
120    _BinaryPredicate __pred_;
121    };
122
123template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
124default_searcher<_ForwardIterator, _BinaryPredicate>
125make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
126{
127    return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
128}
129
130
131_LIBCPP_END_NAMESPACE_LFTS
132
133#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */
134