File: functional

package info (click to toggle)
cppreference-doc 20170409-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 259,872 kB
  • sloc: xml: 570,184; python: 1,923; php: 520; makefile: 168; sh: 25; cpp: 9; ansic: 9
file content (364 lines) | stat: -rw-r--r-- 9,569 bytes parent folder | download | duplicates (2)
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_FUNCTIONAL_H
#define CPPREFERENCE_FUNCTIONAL_H

namespace std {

#if CPPREFERENCE_STDVER >= 2011
template<class R, class... Args>
class function<R(Args...)> {
public:
    typedef R result_type;
    function();
    function(std::nullptr_t);
    function(const function& other);
    function(function&& other);
    template<class F >
    function(F f);
    template<class Alloc >
    function(std::allocator_arg_t, const Alloc& alloc);

    template<class Alloc >
    function(std::allocator_arg_t, const Alloc& alloc,
             std::nullptr_t);

    template<class Alloc >
    function(std::allocator_arg_t, const Alloc& alloc,
             const function& other);

    template<class Alloc >
    function(std::allocator_arg_t, const Alloc& alloc,
             function&& other);

    template<class F, class Alloc >
    function(std::allocator_arg_t, const Alloc& alloc, F f);

    ~function();

    function& operator=(const function& other);
    function& operator=(function&& other);
    function& operator=(std::nullptr_t);

    template<class F >
    function& operator=(F&& f);

    template<class F >
    function& operator=(std::reference_wrapper<F> f);

    void swap(function& other);

    template<class F, class Alloc >
    void assign(F&& f, const Alloc& alloc);

    explicit operator bool() const;

    R operator()(ArgTypes... args) const;

    const std::type_info& target_type() const;

    template<class T >
    T* target();

    template<class T >
    const T* target() const;
};

template<class R, class... Args>
void swap(function<R(Args...)>& lhs, function<R(Args...)>& rhs);

template<class R, class... ArgTypes >
bool operator==(const std::function<R(ArgTypes...)>& f, std::nullptr_t);

template<class R, class... ArgTypes >
bool operator==(std::nullptr_t, const std::function<R(ArgTypes...)>& f);

template<class R, class... ArgTypes >
bool operator!=(const std::function<R(ArgTypes...)>& f, std::nullptr_t);

template<class R, class... ArgTypes >
bool operator!=(std::nullptr_t, const std::function<R(ArgTypes...)>& f);

class bad_function_call : public std::exception {
public:
    bad_function_call();
};

// SIMPLIFIED: actual result is unspecified, std::function<R> is only for
// providing return type
template<class R, class T >
std::function<R> mem_fn(R T::* pm);

template<class F, class... Args >
std::function<R> bind(F&& f, Args&& ... args);

template<class R, class F, class... Args >
std::function<R> bind(F&& f, Args&& ... args);

#if CPPREFERENCE_STDVER >= 2017
template<class F, class... ArgTypes>
std::result_of_t < F&& (ArgTypes&& ...) > invoke(F&& f, ArgTypes&& ... args);
#endif

// SIMPLIFIED: the inherited type is simplified
template<class T >
struct is_bind_expression : std::integral_constant<bool, true> {};

template<class T >
struct is_placeholder : std::integral_constant<bool, true> {};

namespace placeholders { // SIMPLIFIED: the actual type is unspecified
extern int _1;
extern int _2;
extern int _3;
extern int _4;
extern int _5;
extern int _6;
extern int _7;
extern int _8;
extern int _9;
} // namespace placeholders

template<class T>
class reference_wrapper {
public:
    typedef T type;
    // SIMPLIFIED: actual types are dependent on T
    typedef void result_type;
    typedef void argument_type;
    typedef void first_argument_type;
    typedef void second_argument_type;

    reference_wrapper(T& x);
    reference_wrapper(T&& x) = delete;
    reference_wrapper(const reference_wrapper<T>& other);

    reference_wrapper& operator=(const reference_wrapper<T>& other);

    operator T& () const;
    T& get() const;

    template<class... ArgTypes >
    typename std::result_of < T& (ArgTypes&& ...) >::type
    operator()(ArgTypes&& ... args) const;   // only if T is function
};

template<class T >
std::reference_wrapper<T> ref(T& t);

template<class T >
std::reference_wrapper<T> ref(std::reference_wrapper<T> t);

template <class T>
void ref(const T&&) = delete;

template<class T >
std::reference_wrapper<const T> cref(const T& t);

template<class T >
std::reference_wrapper<const T> cref(std::reference_wrapper<T> t);

template <class T>
void cref(const T&&) = delete;

#endif // CPPREFERENCE_STDVER >= 2011

template<class T = void>
struct plus {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct minus {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct multiplies {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct divides {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct modulus {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct negate {
    typedef T result_type;
    typedef T argument_type;
    T operator()(const T& arg) const;
};

template<class T = void>
struct equal_to {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct not_equal_to {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct greater {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct less {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct greater_equal {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct less_equal {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct logical_and {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct logical_or {
    typedef bool result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    bool operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct logical_not {
    typedef bool result_type;
    typedef T argument_type;
    bool operator()(const T& arg) const;
};

template<class T = void>
struct bit_and {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct bit_or {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct bit_xor {
    typedef T result_type;
    typedef T first_argument_type;
    typedef T second_argument_type;
    T operator()(const T& lhs, const T& rhs) const;
};

template<class T = void>
struct bit_not {
    typedef T result_type;
    typedef T argument_type;
    T operator()(const T& arg) const;
};

template<class Predicate >
struct unary_negate {
    typedef bool result_type;
    typedef typename Predicate::argument_type argument_type;

    explicit unary_negate(const Predicate& pred);
    result_type operator()(argument_type const& x) const;
};

template<class Predicate >
struct binary_negate {
    typedef bool result_type;
    typedef typename Predicate::first_argument_type first_argument_type;
    typedef typename Predicate::second_argument_type second_argument_type;

    explicit binary_negate(const Predicate& pred);
    result_type operator()(const T& lhs, const T& rhs) const;
};

template<class Predicate >
std::unary_negate<Predicate> not1(const Predicate& pred);

template<class Predicate >
std::binary_negate<Predicate> not2(const Predicate& pred);

#if CPPREFERENCE_STDVER >= 2011
template<class Key >
struct hash {
    typedef Key argument_type;
    typedef std::size_t result_type;

    std::size_t operator()(const Key& key) const;
};
#endif
} // namespace std

#endif // CPPREFERENCE_FUNCTIONAL_H