-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathfunctional.h
More file actions
127 lines (104 loc) · 3.45 KB
/
functional.h
File metadata and controls
127 lines (104 loc) · 3.45 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
#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:
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 { size_t operator()(Ty val) const; };
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> class function;
template <class R, class... Args> class function<R(Args...)> {
public:
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;
};
} // namespace std
#endif