Scroll to navigation

std::plus(3) C++ Standard Libary std::plus(3)

NAME

std::plus - std::plus

Synopsis

Defined in header <functional> template<> (since C++14) class plus<void>;

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

Member types

Type Definition is_transparent unspecified

Member functions

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

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).

Example

// Run this code

#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

2026.11.10 http://cppreference.com