Namespaces
Variants

std:: multiplies<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 multiplies < void > ;
(C++14 이후)

std:: multiplies < void > 는 매개변수와 반환 타입이 추론된 std::multiplies 의 특수화입니다.

목차

멤버 타입

타입 정의
is_transparent unspecified

멤버 함수

operator()
두 인수의 곱을 반환합니다
(public member function)

std::multiplies<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_multiplies = std::multiplies<void>{}; // "void"는 생략 가능
    constexpr std::complex z1{1.0, 2.0}, z2{3.0, 4.0};
    std::cout << std::showpos
              << complex_multiplies(z1, z2) << ' ' << z1 * z2 << '\n'
              << complex_multiplies(z1, 5.) << ' ' << z1 * 5. << '\n'
              << complex_multiplies(5., z1) << ' ' << 5. * z1 << '\n';
}

출력:

(-5,+10) (-5,+10)
(+5,+10) (+5,+10)
(+5,+10) (+5,+10)