std::plus<void>
來自 cppreference.com
定義於標頭檔案 <functional> |
||
template<> class plus<void>; |
(C++14 起) | |
std::plus<void> 是 std::plus 的特化,其引數與返回型別由推導獲得。
目錄 |
[編輯] 成員型別
型別 | 定義 |
is_transparent
|
未指定 |
[編輯] 成員函式
operator() |
返回兩個引數的和 (public member function) |
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” can be omitted std::string a = "Hello "; const char* b = "world"; std::cout << string_plus(a, b) << '\n'; }
輸出
Hello world