Namespaces
Variants

std:: minus<void>

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
Определено в заголовке <functional>
template <>
class minus < void > ;
(начиная с C++14)

std:: minus < void > является специализацией std::minus с выведенными типами параметров и возвращаемого значения.

Содержание

Типы членов

Тип Определение
is_transparent unspecified

Функции-члены

operator()
возвращает разность двух аргументов
(публичная функция-член)

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" можно опустить
    constexpr std::complex<int> z(4, 2);
    std::cout << complex_minus(z, 1) << '\n';
    std::cout << (z - 1) << '\n';
}

Вывод:

(3,2)
(3,2)