Namespaces
Variants
Views
Actions

std::plus<void>

From cppreference.com
< cpp‎ | utility‎ | functional
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Function objects
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Transparent operator wrappers
plus<>
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

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++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*)
 
Defined in header <functional>
template<>
class plus<void>;
(since C++14)

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

Contents

[edit] Member types

Type Definition
is_transparent unspecified

[edit] Member functions

operator()
returns the sum of two arguments
(public member function) [edit]

std::plus<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 sum of lhs and rhs.

Parameters

lhs, rhs - values to sum

Return value

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

[edit] Example

#include <functional>
#include <iostream>
 
int main()
{
    auto string_plus = std::plus<void>{}; // “void” can be omitted
    std::string a = "Hello ";
    const char* b = "world";
    std::cout << string_plus(a, b) << '\n';
}

Output:

Hello world