xref: /minix3/external/bsd/libc++/dist/libcxx/include/experimental/functional (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc// -*- C++ -*-
2*0a6a1f1dSLionel Sambuc//===-------------------------- functional --------------------------------===//
3*0a6a1f1dSLionel Sambuc//
4*0a6a1f1dSLionel Sambuc//                     The LLVM Compiler Infrastructure
5*0a6a1f1dSLionel Sambuc//
6*0a6a1f1dSLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
7*0a6a1f1dSLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
8*0a6a1f1dSLionel Sambuc//
9*0a6a1f1dSLionel Sambuc//===----------------------------------------------------------------------===//
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL
12*0a6a1f1dSLionel Sambuc#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL
13*0a6a1f1dSLionel Sambuc
14*0a6a1f1dSLionel Sambuc/*
15*0a6a1f1dSLionel Sambuc   experimental/functional synopsis
16*0a6a1f1dSLionel Sambuc
17*0a6a1f1dSLionel Sambuc#include <algorithm>
18*0a6a1f1dSLionel Sambuc
19*0a6a1f1dSLionel Sambucnamespace std {
20*0a6a1f1dSLionel Sambucnamespace experimental {
21*0a6a1f1dSLionel Sambucinline namespace fundamentals_v1 {
22*0a6a1f1dSLionel Sambuc
23*0a6a1f1dSLionel Sambuc    // See C++14 §20.9.9, Function object binders
24*0a6a1f1dSLionel Sambuc    template <class T> constexpr bool is_bind_expression_v
25*0a6a1f1dSLionel Sambuc      = is_bind_expression<T>::value;
26*0a6a1f1dSLionel Sambuc    template <class T> constexpr int is_placeholder_v
27*0a6a1f1dSLionel Sambuc      = is_placeholder<T>::value;
28*0a6a1f1dSLionel Sambuc
29*0a6a1f1dSLionel Sambuc    // 4.2, Class template function
30*0a6a1f1dSLionel Sambuc    template<class> class function; // undefined
31*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes> class function<R(ArgTypes...)>;
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes>
34*0a6a1f1dSLionel Sambuc    void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
35*0a6a1f1dSLionel Sambuc
36*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes>
37*0a6a1f1dSLionel Sambuc    bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
38*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes>
39*0a6a1f1dSLionel Sambuc    bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
40*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes>
41*0a6a1f1dSLionel Sambuc    bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
42*0a6a1f1dSLionel Sambuc    template<class R, class... ArgTypes>
43*0a6a1f1dSLionel Sambuc    bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
44*0a6a1f1dSLionel Sambuc
45*0a6a1f1dSLionel Sambuc    // 4.3, Searchers
46*0a6a1f1dSLionel Sambuc    template<class ForwardIterator, class BinaryPredicate = equal_to<>>
47*0a6a1f1dSLionel Sambuc      class default_searcher;
48*0a6a1f1dSLionel Sambuc
49*0a6a1f1dSLionel Sambuc    template<class RandomAccessIterator,
50*0a6a1f1dSLionel Sambuc             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
51*0a6a1f1dSLionel Sambuc             class BinaryPredicate = equal_to<>>
52*0a6a1f1dSLionel Sambuc      class boyer_moore_searcher;
53*0a6a1f1dSLionel Sambuc
54*0a6a1f1dSLionel Sambuc    template<class RandomAccessIterator,
55*0a6a1f1dSLionel Sambuc             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
56*0a6a1f1dSLionel Sambuc             class BinaryPredicate = equal_to<>>
57*0a6a1f1dSLionel Sambuc      class boyer_moore_horspool_searcher;
58*0a6a1f1dSLionel Sambuc
59*0a6a1f1dSLionel Sambuc    template<class ForwardIterator, class BinaryPredicate = equal_to<>>
60*0a6a1f1dSLionel Sambuc    default_searcher<ForwardIterator, BinaryPredicate>
61*0a6a1f1dSLionel Sambuc    make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last,
62*0a6a1f1dSLionel Sambuc                          BinaryPredicate pred = BinaryPredicate());
63*0a6a1f1dSLionel Sambuc
64*0a6a1f1dSLionel Sambuc    template<class RandomAccessIterator,
65*0a6a1f1dSLionel Sambuc             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
66*0a6a1f1dSLionel Sambuc             class BinaryPredicate = equal_to<>>
67*0a6a1f1dSLionel Sambuc    boyer_moore_searcher<RandomAccessIterator, Hash, BinaryPredicate>
68*0a6a1f1dSLionel Sambuc    make_boyer_moore_searcher(
69*0a6a1f1dSLionel Sambuc        RandomAccessIterator pat_first, RandomAccessIterator pat_last,
70*0a6a1f1dSLionel Sambuc        Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
71*0a6a1f1dSLionel Sambuc
72*0a6a1f1dSLionel Sambuc    template<class RandomAccessIterator,
73*0a6a1f1dSLionel Sambuc             class Hash = hash<typename iterator_traits<RandomAccessIterator>::value_type>,
74*0a6a1f1dSLionel Sambuc             class BinaryPredicate = equal_to<>>
75*0a6a1f1dSLionel Sambuc    boyer_moore_horspool_searcher<RandomAccessIterator, Hash, BinaryPredicate>
76*0a6a1f1dSLionel Sambuc    make_boyer_moore_horspool_searcher(
77*0a6a1f1dSLionel Sambuc        RandomAccessIterator pat_first, RandomAccessIterator pat_last,
78*0a6a1f1dSLionel Sambuc        Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
79*0a6a1f1dSLionel Sambuc
80*0a6a1f1dSLionel Sambuc  } // namespace fundamentals_v1
81*0a6a1f1dSLionel Sambuc  } // namespace experimental
82*0a6a1f1dSLionel Sambuc
83*0a6a1f1dSLionel Sambuc  template<class R, class... ArgTypes, class Alloc>
84*0a6a1f1dSLionel Sambuc  struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>;
85*0a6a1f1dSLionel Sambuc
86*0a6a1f1dSLionel Sambuc} // namespace std
87*0a6a1f1dSLionel Sambuc
88*0a6a1f1dSLionel Sambuc*/
89*0a6a1f1dSLionel Sambuc
90*0a6a1f1dSLionel Sambuc#include <experimental/__config>
91*0a6a1f1dSLionel Sambuc#include <functional>
92*0a6a1f1dSLionel Sambuc#include <algorithm>
93*0a6a1f1dSLionel Sambuc
94*0a6a1f1dSLionel Sambuc#include <__undef_min_max>
95*0a6a1f1dSLionel Sambuc
96*0a6a1f1dSLionel Sambuc#include <__debug>
97*0a6a1f1dSLionel Sambuc
98*0a6a1f1dSLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
99*0a6a1f1dSLionel Sambuc#pragma GCC system_header
100*0a6a1f1dSLionel Sambuc#endif
101*0a6a1f1dSLionel Sambuc
102*0a6a1f1dSLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_LFTS
103*0a6a1f1dSLionel Sambuc
104*0a6a1f1dSLionel Sambuc// default searcher
105*0a6a1f1dSLionel Sambuctemplate<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
106*0a6a1f1dSLionel Sambucclass default_searcher {
107*0a6a1f1dSLionel Sambucpublic:
108*0a6a1f1dSLionel Sambuc    default_searcher(_ForwardIterator __f, _ForwardIterator __l,
109*0a6a1f1dSLionel Sambuc                       _BinaryPredicate __p = _BinaryPredicate())
110*0a6a1f1dSLionel Sambuc        : __first_(__f), __last_(__l), __pred_(__p) {}
111*0a6a1f1dSLionel Sambuc
112*0a6a1f1dSLionel Sambuc    template <typename _ForwardIterator2>
113*0a6a1f1dSLionel Sambuc    _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const {
114*0a6a1f1dSLionel Sambuc        return _VSTD::search(__f, __l, __first_, __last_, __pred_);
115*0a6a1f1dSLionel Sambuc        }
116*0a6a1f1dSLionel Sambuc
117*0a6a1f1dSLionel Sambucprivate:
118*0a6a1f1dSLionel Sambuc    _ForwardIterator __first_;
119*0a6a1f1dSLionel Sambuc    _ForwardIterator __last_;
120*0a6a1f1dSLionel Sambuc    _BinaryPredicate __pred_;
121*0a6a1f1dSLionel Sambuc    };
122*0a6a1f1dSLionel Sambuc
123*0a6a1f1dSLionel Sambuctemplate<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
124*0a6a1f1dSLionel Sambucdefault_searcher<_ForwardIterator, _BinaryPredicate>
125*0a6a1f1dSLionel Sambucmake_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ())
126*0a6a1f1dSLionel Sambuc{
127*0a6a1f1dSLionel Sambuc    return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p);
128*0a6a1f1dSLionel Sambuc}
129*0a6a1f1dSLionel Sambuc
130*0a6a1f1dSLionel Sambuc
131*0a6a1f1dSLionel Sambuc_LIBCPP_END_NAMESPACE_LFTS
132*0a6a1f1dSLionel Sambuc
133*0a6a1f1dSLionel Sambuc#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */
134