std::plus<void>
Определён в заголовочном файле <functional> | ||
|---|---|---|
template<> class plus<void>; | (начиная с C++14) |
std::plus<void> — это специализация std::plus с выводимыми типами параметров и возвращаемого значения.
Типы-члены
| Тип | Определение |
|---|---|
is_transparent | не указано |
Функции-члены
| возвращает сумму двух аргументов (открытая функция-член) |
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” can be omitted
std::string a = "Hello ";
const char* b = "world";
std::cout << string_plus(a, b) << '\n';
}
Вывод:
Hello world
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/utility/functional/plus_void