std::minus<void>
Определён в заголовке <functional> | ||
|---|---|---|
template<> class minus<void>; | (начиная с C++14) |
std::minus<void> — это специализация std::minus с выводимыми типами параметров и возвращаемого значения.
Типы-члены
| Тип | Определение |
|---|---|
is_transparent | не указано |
Функции-члены
| возвращает разность двух аргументов (открытая функция-член) |
std::minus<void>::operator()
template< class T, class U >
constexpr auto operator()( T&& lhs, U&& rhs ) const
-> decltype(std::forward<T>(lhs) - std::forward<U>(rhs));
|
Возвращает разность lhs и rhs.
Параметры
| lhs, rhs | - | значения для вычитания |
Возвращаемое значение
std::forward<T>(lhs) - std::forward<U>(rhs).
Пример
#include <complex>
#include <functional>
#include <iostream>
int main()
{
auto complex_minus = std::minus<void>{}; // “void” can be omitted
constexpr std::complex<int> z(4, 2);
std::cout << complex_minus(z, 1) << '\n';
std::cout << (z - 1) << '\n';
}
Вывод:
(3,2) (3,2)
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/utility/functional/minus_void