From Jason Turner

[depr.function.pointer.adaptors]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpibk36k94/{from.md → to.md} +0 -51
tmp/tmpibk36k94/{from.md → to.md} RENAMED
@@ -1,51 +0,0 @@
1
- #### Adaptors for pointers to functions <a id="depr.function.pointer.adaptors">[[depr.function.pointer.adaptors]]</a>
2
-
3
- To allow pointers to (unary and binary) functions to work with function
4
- adaptors the library provides:
5
-
6
- ``` cpp
7
- template <class Arg, class Result>
8
- class pointer_to_unary_function : public unary_function<Arg, Result> {
9
- public:
10
- explicit pointer_to_unary_function(Result (*f)(Arg));
11
- Result operator()(Arg x) const;
12
- };
13
- ```
14
-
15
- `operator()` returns `f(x)`.
16
-
17
- ``` cpp
18
- template <class Arg, class Result>
19
- pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));
20
- ```
21
-
22
- *Returns:* `pointer_to_unary_function<Arg, Result>(f)`.
23
-
24
- ``` cpp
25
- template <class Arg1, class Arg2, class Result>
26
- class pointer_to_binary_function :
27
- public binary_function<Arg1,Arg2,Result> {
28
- public:
29
- explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2));
30
- Result operator()(Arg1 x, Arg2 y) const;
31
- };
32
- ```
33
-
34
- `operator()` returns `f(x,y)`.
35
-
36
- ``` cpp
37
- template <class Arg1, class Arg2, class Result>
38
- pointer_to_binary_function<Arg1,Arg2,Result>
39
- ptr_fun(Result (*f)(Arg1, Arg2));
40
- ```
41
-
42
- *Returns:* `pointer_to_binary_function<Arg1,Arg2,Result>(f)`.
43
-
44
- ``` cpp
45
- int compare(const char*, const char*);
46
- replace_if(v.begin(), v.end(),
47
- not1(bind2nd(ptr_fun(compare), "abc")), "def");
48
- ```
49
-
50
- replaces each `abc` with `def` in sequence `v`.
51
-