From Jason Turner

[arithmetic.operations]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpkbnh_y4p/{from.md → to.md} +78 -12
tmp/tmpkbnh_y4p/{from.md → to.md} RENAMED
@@ -2,69 +2,135 @@
2
 
3
  The library provides basic function object classes for all of the
4
  arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
5
 
6
  ``` cpp
7
- template <class T> struct plus {
8
- T operator()(const T& x, const T& y) const;
9
  typedef T first_argument_type;
10
  typedef T second_argument_type;
11
  typedef T result_type;
12
  };
13
  ```
14
 
15
  `operator()` returns `x + y`.
16
 
17
  ``` cpp
18
- template <class T> struct minus {
19
- T operator()(const T& x, const T& y) const;
20
  typedef T first_argument_type;
21
  typedef T second_argument_type;
22
  typedef T result_type;
23
  };
24
  ```
25
 
26
  `operator()` returns `x - y`.
27
 
28
  ``` cpp
29
- template <class T> struct multiplies {
30
- T operator()(const T& x, const T& y) const;
31
  typedef T first_argument_type;
32
  typedef T second_argument_type;
33
  typedef T result_type;
34
  };
35
  ```
36
 
37
  `operator()` returns `x * y`.
38
 
39
  ``` cpp
40
- template <class T> struct divides {
41
- T operator()(const T& x, const T& y) const;
42
  typedef T first_argument_type;
43
  typedef T second_argument_type;
44
  typedef T result_type;
45
  };
46
  ```
47
 
48
  `operator()` returns `x / y`.
49
 
50
  ``` cpp
51
- template <class T> struct modulus {
52
- T operator()(const T& x, const T& y) const;
53
  typedef T first_argument_type;
54
  typedef T second_argument_type;
55
  typedef T result_type;
56
  };
57
  ```
58
 
59
  `operator()` returns `x % y`.
60
 
61
  ``` cpp
62
- template <class T> struct negate {
63
- T operator()(const T& x) const;
64
  typedef T argument_type;
65
  typedef T result_type;
66
  };
67
  ```
68
 
69
  `operator()` returns `-x`.
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  The library provides basic function object classes for all of the
4
  arithmetic operators in the language ([[expr.mul]], [[expr.add]]).
5
 
6
  ``` cpp
7
+ template <class T = void> struct plus {
8
+ constexpr T operator()(const T& x, const T& y) const;
9
  typedef T first_argument_type;
10
  typedef T second_argument_type;
11
  typedef T result_type;
12
  };
13
  ```
14
 
15
  `operator()` returns `x + y`.
16
 
17
  ``` cpp
18
+ template <class T = void> struct minus {
19
+ constexpr T operator()(const T& x, const T& y) const;
20
  typedef T first_argument_type;
21
  typedef T second_argument_type;
22
  typedef T result_type;
23
  };
24
  ```
25
 
26
  `operator()` returns `x - y`.
27
 
28
  ``` cpp
29
+ template <class T = void> struct multiplies {
30
+ constexpr T operator()(const T& x, const T& y) const;
31
  typedef T first_argument_type;
32
  typedef T second_argument_type;
33
  typedef T result_type;
34
  };
35
  ```
36
 
37
  `operator()` returns `x * y`.
38
 
39
  ``` cpp
40
+ template <class T = void> struct divides {
41
+ constexpr T operator()(const T& x, const T& y) const;
42
  typedef T first_argument_type;
43
  typedef T second_argument_type;
44
  typedef T result_type;
45
  };
46
  ```
47
 
48
  `operator()` returns `x / y`.
49
 
50
  ``` cpp
51
+ template <class T = void> struct modulus {
52
+ constexpr T operator()(const T& x, const T& y) const;
53
  typedef T first_argument_type;
54
  typedef T second_argument_type;
55
  typedef T result_type;
56
  };
57
  ```
58
 
59
  `operator()` returns `x % y`.
60
 
61
  ``` cpp
62
+ template <class T = void> struct negate {
63
+ constexpr T operator()(const T& x) const;
64
  typedef T argument_type;
65
  typedef T result_type;
66
  };
67
  ```
68
 
69
  `operator()` returns `-x`.
70
 
71
+ ``` cpp
72
+ template <> struct plus<void> {
73
+ template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
74
+ -> decltype(std::forward<T>(t) + std::forward<U>(u));
75
+
76
+ typedef unspecified is_transparent;
77
+ };
78
+ ```
79
+
80
+ `operator()` returns `std::forward<T>(t) + std::forward<U>(u)`.
81
+
82
+ ``` cpp
83
+ template <> struct minus<void> {
84
+ template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
85
+ -> decltype(std::forward<T>(t) - std::forward<U>(u));
86
+
87
+ typedef unspecified is_transparent;
88
+ };
89
+ ```
90
+
91
+ `operator()` returns `std::forward<T>(t) - std::forward<U>(u)`.
92
+
93
+ ``` cpp
94
+ template <> struct multiplies<void> {
95
+ template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
96
+ -> decltype(std::forward<T>(t) * std::forward<U>(u));
97
+
98
+ typedef unspecified is_transparent;
99
+ };
100
+ ```
101
+
102
+ `operator()` returns `std::forward<T>(t) * std::forward<U>(u)`.
103
+
104
+ ``` cpp
105
+ template <> struct divides<void> {
106
+ template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
107
+ -> decltype(std::forward<T>(t) / std::forward<U>(u));
108
+
109
+ typedef unspecified is_transparent;
110
+ };
111
+ ```
112
+
113
+ `operator()` returns `std::forward<T>(t) / std::forward<U>(u)`.
114
+
115
+ ``` cpp
116
+ template <> struct modulus<void> {
117
+ template <class T, class U> constexpr auto operator()(T&& t, U&& u) const
118
+ -> decltype(std::forward<T>(t) % std::forward<U>(u));
119
+
120
+ typedef unspecified is_transparent;
121
+ };
122
+ ```
123
+
124
+ `operator()` returns `std::forward<T>(t) % std::forward<U>(u)`.
125
+
126
+ ``` cpp
127
+ template <> struct negate<void> {
128
+ template <class T> constexpr auto operator()(T&& t) const
129
+ -> decltype(-std::forward<T>(t));
130
+
131
+ typedef unspecified is_transparent;
132
+ };
133
+ ```
134
+
135
+ `operator()` returns `-std::forward<T>(t)`.
136
+