-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathfunctional.h
More file actions
168 lines (139 loc) · 4.72 KB
/
functional.h
File metadata and controls
168 lines (139 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#ifndef _GHLIBCPP_FUNCTIONAL
#define _GHLIBCPP_FUNCTIONAL
#include <utility>
namespace std {
typedef unsigned long size_t;
namespace placeholders {
template <int _Np> struct __ph {};
extern const __ph<1> _1;
extern const __ph<2> _2;
} // namespace placeholders
template <class Fn, class... Args> class binder {
public:
using result_type = int; // deprecated in C++17
template <class TFn, class... TArgs>
constexpr binder(TFn &&f, TArgs &&...args) noexcept {}
template <class... CallArgs>
constexpr decltype(auto) operator()(CallArgs &&...args);
};
template <typename ArgumentType, typename ResultType> struct unary_function {};
template <class Arg1, class Arg2, class Result> struct binary_function {
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
template <class Fn> class binder1st {
protected:
Fn op;
};
template <class Fn> class binder2nd {
protected:
Fn op;
};
template <class F, class Args> binder<F, Args> bind(F &&f, Args &&args, ...);
template <class F, class T> binder1st<F> bind1st(const F &f, const T &x);
template <class F, class T> binder2nd<F> bind2nd(const F &f, const T &x);
template <class T> class reference_wrapper {
reference_wrapper(T &ref) : ref(addressof(ref)) {}
reference_wrapper(T &&ref) = delete;
operator T &() const { return *ref; }
private:
T *ref;
};
template <class T> reference_wrapper<T> ref(T &t) noexcept;
template <class T> void ref(const T &&t) = delete;
template <class T> reference_wrapper<T> ref(reference_wrapper<T> t) noexcept;
template <class Ty> struct hash {
using result_type = size_t; // deprecated in C++17
using argument_type = Ty; // deprecated in C++17
size_t operator()(Ty val) const;
};
template <class F> class mem_fn_result {
public:
using result_type = int; // deprecated in C++17
};
template <class F> mem_fn_result<F> mem_fn(F f);
template <class Arg, class Result>
class pointer_to_unary_function : public unary_function<Arg, Result> {
public:
explicit pointer_to_unary_function(Result (*f)(Arg)) : pfunc(f) {}
Result operator()(Arg x) const { return pfunc(x); }
};
template <class Arg1, class Arg2, class Result>
class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> {
public:
explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)) : pfunc(f) {}
Result operator()(Arg1 x, Arg2 y) const { return pfunc(x, y); }
};
template <class Arg, class Result>
pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));
template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result> ptr_fun(Result (*f)(Arg1, Arg2));
template <class T> struct equal_to {
bool operator()(const T &x, const T &y) const { return x == y; }
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
template <class Predicate> class unary_negate {
public:
unary_negate() = default;
explicit unary_negate(const Predicate &pred);
bool operator()(const typename Predicate::argument_type &x) const;
};
template <class Predicate> class binary_negate {
public:
binary_negate() = default;
explicit binary_negate(const Predicate &pred);
bool operator()(const typename Predicate::first_argument_type &x,
const typename Predicate::second_argument_type &y) const;
};
template <class> class function;
template <class R, class... Args> class function<R(Args...)> {
public:
using result_type = R; // deprecated in C++17
function();
template <class F> function(F&& f);
template <class F> function &operator=(F &&);
};
template <typename T>
struct less {
bool operator()(const T &x, const T &y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
template <typename T>
struct less_equal {
bool operator()(const T &x, const T &y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
template <typename T>
struct greater {
bool operator()(const T &x, const T &y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
template <typename T>
struct greater_equal {
bool operator()(const T &x, const T &y) const;
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
template <class T = void> struct plus {
using result_type = T; // deprecated in C++17
using first_argument_type = T; // deprecated in C++17
using second_argument_type = T; // deprecated in C++17
T operator()(const T &x, const T &y) const;
};
template <class T = void> struct negate {
using result_type = T; // deprecated in C++17
using argument_type = T; // deprecated in C++17
T operator()(const T &x) const;
};
} // namespace std
#endif