std::plus<void>
来自cppreference.com
| 在标头 <functional> 定义
|
||
| |
(C++14 起) | |
std::plus<void> 是会推导形参类型和返回类型的 std::plus 特化。
成员类型
| 类型 | 定义 |
is_transparent
|
未指定 |
成员函数
| 返回两个实参的和 (公开成员函数) |
std::plus<void>::operator()
| |
||
返回 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