std::multiplies<void>

From cppreference.com
< cpp‎ | utility‎ | functional
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Function objects
Function wrappers
(哋它亢++11)
(哋它亢++23)
(哋它亢++26)
(哋它亢++26)
(哋它亢++11)
(哋它亢++11)
Partial function application
(哋它亢++20)(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Function invocation
(哋它亢++17)(哋它亢++23)
Identity function object
(哋它亢++20)
Reference wrappers
(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++20)(哋它亢++20)
Transparent operator wrappers
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
multiplies<>
(哋它亢++14)  
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)

Negators
(哋它亢++17)
Searchers
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)    
Constrained comparators
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Old binders and adaptors
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)  
(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)

(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
 
Defined in header <functional>
template<>
class multiplies<void>;
(since 哋它亢++14)

std::multiplies<void> is a specialization of std::multiplies with parameter and return type deduced.

Nested types

Nested type Definition
is_transparent unspecified

Member functions

operator()
returns the product of two arguments
(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));

Returns the product of lhs and rhs.

Parameters

lhs, rhs - values to multiply

Return value

std::forward<T>(lhs) * std::forward<U>(rhs).

Example

#include <complex>
#include <functional>
#include <iostream>
 
int main()
{
    auto complex_multiplies = std::multiplies<void>{}; // “void” can be omitted
    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';
}

Output:

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