Namespaces
Variants

std:: divides

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 T >
struct divides ;
(C++14まで)
template < class T = void >
struct divides ;
(C++14から)

除算を実行する関数オブジェクト。実質的に型 T の2つのインスタンスに対して operator / を呼び出します。

目次

翻訳の説明: - 「Contents」を「目次」に翻訳しました - C++固有の用語(Specializations、Member types、Member functions、std::divides::operator()、Parameters、Return value、Exceptions、Possible implementation)は原文のまま保持しました - HTMLタグ、属性、数値はすべて変更せず保持しました - プロフェッショナルで正確な翻訳を心がけました

特殊化

標準ライブラリは、 T が指定されていない場合の std::divides の特殊化を提供しており、 パラメータ型と戻り値の型が推論されるようになっています。

パラメータと戻り値の型を推論する x / y を実装する関数オブジェクト
(クラステンプレートの特殊化)
(C++14以降)

メンバー型

定義
result_type (C++17で非推奨) (C++20で削除) T
first_argument_type (C++17で非推奨) (C++20で削除) T
second_argument_type (C++17で非推奨) (C++20で削除) T

これらのメンバ型は、公開継承によって std:: binary_function < T, T, T > から取得されます。

(C++11まで)

メンバー関数

operator()
第1引数を第2引数で除算した結果を返す
(公開メンバ関数)

std::divides:: operator()

T operator ( ) ( const T & lhs, const T & rhs ) const ;
(constexpr since C++14)

lhs rhs で除算した結果を返します。

パラメータ

lhs, rhs - 除算する値

戻り値

lhs / rhs の結果。

例外

実装定義の例外をスローする可能性があります。

実装例

constexpr T operator()(const T& lhs, const T& rhs) const 
{
    return lhs / rhs;
}