Namespaces
Variants

std:: plus<void>

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
ヘッダーで定義 <functional>
template <>
class plus < void > ;
(C++14以降)

std:: plus < void > は、パラメータと戻り値の型が推論される std::plus の特殊化です。

目次

翻訳の説明: - 「Contents」を「目次」に翻訳 - HTMLタグ、属性、 内のC++コード(std::plus<void>:: operator())は翻訳せず保持 - C++専門用語(Member types、Member functions、Parameters、Return value、Example)は翻訳せず保持 - 数値や構造は完全に保持

メンバー型

定義
is_transparent unspecified

メンバー関数

operator()
2つの引数の合計を返す
(公開メンバ関数)

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” は省略可能
    std::string a = "Hello ";
    const char* b = "world";
    std::cout << string_plus(a, b) << '\n';
}

出力:

Hello world