Namespaces
Variants

std:: plus<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 plus < void > ;
(начиная с C++14)

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

Содержание

Типы членов

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

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

operator()
возвращает сумму двух аргументов
(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 ) ) ;

Возвращает сумму lhs и rhs .

Параметры

lhs, rhs - значения для суммирования

Возвращаемое значение

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

Пример

#include <functional>
#include <iostream>
int main()
{
    auto string_plus = std::plus<void>{}; // “void” можно опустить
    std::string a = "Hello ";
    const char* b = "world";
    std::cout << string_plus(a, b) << '\n';
}

Вывод:

Hello world