◐ Shell
clean mode source ↗

std::plus<void> - cppreference.com

来自cppreference.com

std::plus<void> 是会推导形参类型和返回类型的 std::plus 特化。

成员类型

成员函数

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

返回 lhsrhs 的和。

参数

返回值

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';
}

输出: