std:: plus<void>
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<functional>
|
||
|
template
<>
class plus < void > ; |
(C++14 起) | |
std:: plus < void > 是 std::plus 的特化版本,其参数和返回类型由编译器自动推导。
目录 |
成员类型
| 类型 | 定义 |
is_transparent
|
未指定 |
成员函数
|
operator()
|
返回两个参数的和
(公开成员函数) |
std::plus<void>:: operator()
|
template
<
class
T,
class
U
>
constexpr
auto
operator
(
)
(
T
&&
lhs, U
&&
rhs
)
const
|
||
返回 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