• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Concepts
2========
3
4ConstFunctionObject
5-------------------
6
7Is an object with a `const` call operator:
8
9```cpp
10concept ConstFunctionObject
11{
12    template<class... Ts>
13    auto operator()(Ts&&...) const;
14};
15```
16
17#### Requirements:
18
19The type `F` satisfies `ConstFunctionObject` if
20
21* The type `F` satisfies `std::is_object`, and
22
23Given
24
25* `f`, an object of type `const F`
26* `args...`, suitable argument list, which may be empty
27
28```eval_rst
29+----------------+--------------------------+
30| Expression     | Requirements             |
31+================+==========================+
32| ``f(args...)`` | performs a function call |
33+----------------+--------------------------+
34```
35
36NullaryFunctionObject
37---------------------
38
39Is an object with a `const` call operator that accepts no parameters:
40
41```cpp
42concept NullaryFunctionObject
43{
44    auto operator()() const;
45};
46```
47
48#### Requirements:
49
50* `ConstFunctionObject`
51
52Given
53
54* `f`, an object of type `const F`
55
56```eval_rst
57+----------------+--------------------------+
58| Expression     | Requirements             |
59+================+==========================+
60| ``f()``        | performs a function call |
61+----------------+--------------------------+
62```
63
64UnaryFunctionObject
65-------------------
66
67Is an object with a `const` call operator that accepts one parameter:
68
69```cpp
70concept UnaryFunctionObject
71{
72    template<class T>
73    auto operator()(T&&) const;
74};
75```
76
77#### Requirements:
78
79* `ConstFunctionObject`
80
81Given
82
83* `f`, an object of type `const F`
84* `arg`, a single argument
85
86```eval_rst
87+----------------+--------------------------+
88| Expression     | Requirements             |
89+================+==========================+
90| ``f(arg)``     | performs a function call |
91+----------------+--------------------------+
92```
93
94BinaryFunctionObject
95--------------------
96
97Is an object with a `const` call operator that accepts two parameter:
98
99```cpp
100concept UnaryFunctionObject
101{
102    template<class T, class U>
103    auto operator()(T&&, U&&) const;
104};
105```
106
107#### Requirements:
108
109* `ConstFunctionObject`
110
111Given
112
113* `f`, an object of type `const F`
114* `arg1`, a single argument
115* `arg2`, a single argument
116
117```eval_rst
118+-------------------+--------------------------+
119| Expression        | Requirements             |
120+===================+==========================+
121| ``f(arg1, arg2)`` | performs a function call |
122+-------------------+--------------------------+
123```
124
125MutableFunctionObject
126---------------------
127
128Is an object with a `mutable` call operator:
129
130```cpp
131concept MutableFunctionObject
132{
133    template<class... Ts>
134    auto operator()(Ts&&...);
135};
136```
137
138#### Requirements:
139
140The type `F` satisfies `MutableFunctionObject` if
141
142* The type `F` satisfies `std::is_object`, and
143
144Given
145
146* `f`, an object of type `F`
147* `args...`, suitable argument list, which may be empty
148
149```eval_rst
150+----------------+--------------------------+
151| Expression     | Requirements             |
152+================+==========================+
153| ``f(args...)`` | performs a function call |
154+----------------+--------------------------+
155```
156
157EvaluatableFunctionObject
158-------------------------
159
160Is an object that is either a `NullaryFunctionObject`, or it is an `UnaryFuntionObject` that accepts the `identity` function as a parameter.
161
162#### Requirements:
163
164* `NullaryFunctionObject`
165
166Given
167
168* `f`, an object of type `const F`
169
170```eval_rst
171+----------------+--------------------------+
172| Expression     | Requirements             |
173+================+==========================+
174| ``f()``        | performs a function call |
175+----------------+--------------------------+
176```
177
178Or:
179
180* `UnaryFuntionObject`
181
182Given
183
184* `f`, an object of type `const F`
185* `identity`, which is the identity function
186
187```eval_rst
188+-----------------+--------------------------+
189| Expression      | Requirements             |
190+=================+==========================+
191| ``f(identity)`` | performs a function call |
192+-----------------+--------------------------+
193```
194
195Invocable
196---------
197
198Is an object for which the `INVOKE` operation can be applied.
199
200#### Requirements:
201
202The type `T` satisfies `Invocable` if
203
204Given
205
206* `f`, an object of type `T`
207* `Args...`, suitable list of argument types
208
209The following expressions must be valid:
210
211```eval_rst
212+----------------------------------------+-------------------------------------------------------+
213| Expression                             | Requirements                                          |
214+========================================+=======================================================+
215| ``INVOKE(f, std::declval<Args>()...)`` | the expression is well-formed in unevaluated context  |
216+----------------------------------------+-------------------------------------------------------+
217```
218
219where `INVOKE(f, x, xs...)` is defined as follows:
220
221* if `f` is a pointer to member function of class `U`:
222
223    - If `std::is_base_of<U, std::decay_t<decltype(x)>>()` is true, then `INVOKE(f, x, xs...)` is equivalent to `(x.*f)(xs...)`
224    - otherwise, if `std::decay_t<decltype(x)>` is a specialization of `std::reference_wrapper`, then `INVOKE(f, x, xs...)` is equivalent to `(x.get().*f)(xs...)`
225    - otherwise, if x does not satisfy the previous items, then `INVOKE(f, x, xs...)` is equivalent to `((*x).*f)(xs...)`.
226
227* otherwise, if `f` is a pointer to data member of class `U`:
228
229    - If `std::is_base_of<U, std::decay_t<decltype(x)>>()` is true, then `INVOKE(f, x)` is equivalent to `x.*f`
230    - otherwise, if `std::decay_t<decltype(x)>` is a specialization of `std::reference_wrapper`, then `INVOKE(f, x)` is equivalent to `x.get().*f`
231    - otherwise, if `x` does not satisfy the previous items, then `INVOKE(f, x)` is equivalent to `(*x).*f`
232
233* otherwise, `INVOKE(f, x, xs...)` is equivalent to `f(x, xs...)`
234
235ConstInvocable
236-------------
237
238Is an object for which the `INVOKE` operation can be applied.
239
240#### Requirements:
241
242The type `T` satisfies `ConstInvocable` if
243
244Given
245
246* `f`, an object of type `const T`
247* `Args...`, suitable list of argument types
248
249The following expressions must be valid:
250
251```eval_rst
252+----------------------------------------+-------------------------------------------------------+
253| Expression                             | Requirements                                          |
254+========================================+=======================================================+
255| ``INVOKE(f, std::declval<Args>()...)`` | the expression is well-formed in unevaluated context  |
256+----------------------------------------+-------------------------------------------------------+
257```
258
259where `INVOKE(f, x, xs...)` is defined as follows:
260
261* if `f` is a pointer to member function of class `U`:
262
263    - If `std::is_base_of<U, std::decay_t<decltype(x)>>()` is true, then `INVOKE(f, x, xs...)` is equivalent to `(x.*f)(xs...)`
264    - otherwise, if `std::decay_t<decltype(x)>` is a specialization of `std::reference_wrapper`, then `INVOKE(f, x, xs...)` is equivalent to `(x.get().*f)(xs...)`
265    - otherwise, if x does not satisfy the previous items, then `INVOKE(f, x, xs...)` is equivalent to `((*x).*f)(xs...)`.
266
267* otherwise, if `f` is a pointer to data member of class `U`:
268
269    - If `std::is_base_of<U, std::decay_t<decltype(x)>>()` is true, then `INVOKE(f, x)` is equivalent to `x.*f`
270    - otherwise, if `std::decay_t<decltype(x)>` is a specialization of `std::reference_wrapper`, then `INVOKE(f, x)` is equivalent to `x.get().*f`
271    - otherwise, if `x` does not satisfy the previous items, then `INVOKE(f, x)` is equivalent to `(*x).*f`
272
273* otherwise, `INVOKE(f, x, xs...)` is equivalent to `f(x, xs...)`
274
275UnaryInvocable
276--------------
277
278Is an object for which the `INVOKE` operation can be applied with one parameter.
279
280#### Requirements:
281
282* `ConstInvocable`
283
284Given
285
286* `f`, an object of type `const F`
287* `arg`, a single argument
288
289```eval_rst
290+----------------------------------------+-------------------------------------------------------+
291| Expression                             | Requirements                                          |
292+========================================+=======================================================+
293| ``INVOKE(f, arg)``                     | the expression is well-formed in unevaluated context  |
294+----------------------------------------+-------------------------------------------------------+
295```
296
297BinaryInvocable
298---------------
299
300Is an object for which the `INVOKE` operation can be applied with two parameters.
301
302#### Requirements:
303
304* `ConstInvocable`
305
306Given
307
308* `f`, an object of type `const F`
309* `arg1`, a single argument
310* `arg2`, a single argument
311
312```eval_rst
313+----------------------------------------+-------------------------------------------------------+
314| Expression                             | Requirements                                          |
315+========================================+=======================================================+
316| ``INVOKE(f, arg1, arg2)``              | the expression is well-formed in unevaluated context  |
317+----------------------------------------+-------------------------------------------------------+
318```
319
320Metafunction
321------------
322
323Given
324
325* `f`, a type or a template
326* `args...`, any suitable type, which may be empty
327
328```eval_rst
329+--------------------------+--------------------------------------------+
330| Expression               | Requirements                               |
331+==========================+============================================+
332| ``f::type``              | The type is the result of the metafunction |
333+--------------------------+--------------------------------------------+
334| ``f<args...>::type``     | The type is the result of the metafunction |
335+--------------------------+--------------------------------------------+
336```
337
338MetafunctionClass
339-----------------
340
341Given
342
343* `f`, a type or a template
344* `args...`, any suitable type, which may be empty
345
346```eval_rst
347+-----------------------------+--------------------------------------------+
348| Expression                  | Requirements                               |
349+=============================+============================================+
350| ``f::apply::type``          | The type is the result of the metafunction |
351+-----------------------------+--------------------------------------------+
352| ``f::apply<args...>::type`` | The type is the result of the metafunction |
353+-----------------------------+--------------------------------------------+
354```
355