269 lines
7.3 KiB
Markdown
269 lines
7.3 KiB
Markdown
[arithmetic.operations]
|
||
|
||
# 22 General utilities library [[utilities]](./#utilities)
|
||
|
||
## 22.10 Function objects [[function.objects]](function.objects#arithmetic.operations)
|
||
|
||
### 22.10.7 Arithmetic operations [arithmetic.operations]
|
||
|
||
#### [22.10.7.1](#general) General [[arithmetic.operations.general]](arithmetic.operations.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11999)
|
||
|
||
The library provides basic function object classes for all of the arithmetic
|
||
operators in the language ([[expr.mul]](expr.mul "7.6.5 Multiplicative operators"), [[expr.add]](expr.add "7.6.6 Additive operators"))[.](#general-1.sentence-1)
|
||
|
||
#### [22.10.7.2](#plus) Class template plus [[arithmetic.operations.plus]](arithmetic.operations.plus)
|
||
|
||
[ð](#lib:plus)
|
||
|
||
`template<class T = void> struct plus {
|
||
constexpr T operator()(const T& x, const T& y) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),plus)
|
||
|
||
`constexpr T operator()(const T& x, const T& y) const;
|
||
`
|
||
|
||
[1](#plus-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12018)
|
||
|
||
*Returns*: x + y[.](#plus-1.sentence-1)
|
||
|
||
[ð](#lib:plus%3c%3e)
|
||
|
||
`template<> struct plus<void> {
|
||
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) + std::forward<U>(u));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),plus%3c%3e)
|
||
|
||
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) + std::forward<U>(u));
|
||
`
|
||
|
||
[2](#plus-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12040)
|
||
|
||
*Returns*: std::forward<T>(t) + std::forward<U>(u)[.](#plus-2.sentence-1)
|
||
|
||
#### [22.10.7.3](#minus) Class template minus [[arithmetic.operations.minus]](arithmetic.operations.minus)
|
||
|
||
[ð](#lib:minus)
|
||
|
||
`template<class T = void> struct minus {
|
||
constexpr T operator()(const T& x, const T& y) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),minus)
|
||
|
||
`constexpr T operator()(const T& x, const T& y) const;
|
||
`
|
||
|
||
[1](#minus-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12060)
|
||
|
||
*Returns*: x - y[.](#minus-1.sentence-1)
|
||
|
||
[ð](#lib:minus%3c%3e)
|
||
|
||
`template<> struct minus<void> {
|
||
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) - std::forward<U>(u));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),minus%3c%3e)
|
||
|
||
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) - std::forward<U>(u));
|
||
`
|
||
|
||
[2](#minus-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12082)
|
||
|
||
*Returns*: std::forward<T>(t) - std::forward<U>(u)[.](#minus-2.sentence-1)
|
||
|
||
#### [22.10.7.4](#multiplies) Class template multiplies [[arithmetic.operations.multiplies]](arithmetic.operations.multiplies)
|
||
|
||
[ð](#lib:multiplies)
|
||
|
||
`template<class T = void> struct multiplies {
|
||
constexpr T operator()(const T& x, const T& y) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),multiplies)
|
||
|
||
`constexpr T operator()(const T& x, const T& y) const;
|
||
`
|
||
|
||
[1](#multiplies-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12102)
|
||
|
||
*Returns*: x * y[.](#multiplies-1.sentence-1)
|
||
|
||
[ð](#lib:multiplies%3c%3e)
|
||
|
||
`template<> struct multiplies<void> {
|
||
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) * std::forward<U>(u));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),multiplies%3c%3e)
|
||
|
||
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) * std::forward<U>(u));
|
||
`
|
||
|
||
[2](#multiplies-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12124)
|
||
|
||
*Returns*: std::forward<T>(t) * std::forward<U>(u)[.](#multiplies-2.sentence-1)
|
||
|
||
#### [22.10.7.5](#divides) Class template divides [[arithmetic.operations.divides]](arithmetic.operations.divides)
|
||
|
||
[ð](#lib:divides)
|
||
|
||
`template<class T = void> struct divides {
|
||
constexpr T operator()(const T& x, const T& y) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),divides)
|
||
|
||
`constexpr T operator()(const T& x, const T& y) const;
|
||
`
|
||
|
||
[1](#divides-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12144)
|
||
|
||
*Returns*: x / y[.](#divides-1.sentence-1)
|
||
|
||
[ð](#lib:divides%3c%3e)
|
||
|
||
`template<> struct divides<void> {
|
||
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) / std::forward<U>(u));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),divides%3c%3e)
|
||
|
||
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) / std::forward<U>(u));
|
||
`
|
||
|
||
[2](#divides-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12166)
|
||
|
||
*Returns*: std::forward<T>(t) / std::forward<U>(u)[.](#divides-2.sentence-1)
|
||
|
||
#### [22.10.7.6](#modulus) Class template modulus [[arithmetic.operations.modulus]](arithmetic.operations.modulus)
|
||
|
||
[ð](#lib:modulus)
|
||
|
||
`template<class T = void> struct modulus {
|
||
constexpr T operator()(const T& x, const T& y) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),modulus)
|
||
|
||
`constexpr T operator()(const T& x, const T& y) const;
|
||
`
|
||
|
||
[1](#modulus-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12186)
|
||
|
||
*Returns*: x % y[.](#modulus-1.sentence-1)
|
||
|
||
[ð](#lib:modulus%3c%3e)
|
||
|
||
`template<> struct modulus<void> {
|
||
template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) % std::forward<U>(u));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),modulus%3c%3e)
|
||
|
||
`template<class T, class U> constexpr auto operator()(T&& t, U&& u) const
|
||
-> decltype(std::forward<T>(t) % std::forward<U>(u));
|
||
`
|
||
|
||
[2](#modulus-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12208)
|
||
|
||
*Returns*: std::forward<T>(t) % std::forward<U>(u)[.](#modulus-2.sentence-1)
|
||
|
||
#### [22.10.7.7](#negate) Class template negate [[arithmetic.operations.negate]](arithmetic.operations.negate)
|
||
|
||
[ð](#lib:negate)
|
||
|
||
`template<class T = void> struct negate {
|
||
constexpr T operator()(const T& x) const;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),negate)
|
||
|
||
`constexpr T operator()(const T& x) const;
|
||
`
|
||
|
||
[1](#negate-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12228)
|
||
|
||
*Returns*: -x[.](#negate-1.sentence-1)
|
||
|
||
[ð](#lib:negate%3c%3e)
|
||
|
||
`template<> struct negate<void> {
|
||
template<class T> constexpr auto operator()(T&& t) const
|
||
-> decltype(-std::forward<T>(t));
|
||
|
||
using is_transparent = unspecified;
|
||
};
|
||
`
|
||
|
||
[ð](#lib:operator(),negate%3c%3e)
|
||
|
||
`template<class T> constexpr auto operator()(T&& t) const
|
||
-> decltype(-std::forward<T>(t));
|
||
`
|
||
|
||
[2](#negate-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L12250)
|
||
|
||
*Returns*: -std::forward<T>(t)[.](#negate-2.sentence-1)
|