名前空間
変種
操作

「cpp/utility/functional/modulus」の版間の差分

提供: cppreference.com
< cpp‎ | utility‎ | functional
(Translated from the English version using Google Translate)
 
 
(2人の利用者による、間の3版が非表示)
1行: 1行:
{{tr_note}}
 
 
{{cpp/title|modulus}}
 
{{cpp/title|modulus}}
 
{{cpp/utility/functional/navbar}}
 
{{cpp/utility/functional/navbar}}
{{ddcl list begin}}
+
 
{{ddcl list header | functional }}
+
{{begin}}
{{ddcl list item |
+
{{header | functional }}
 +
{{
 +
|
 
template< class T >
 
template< class T >
 
struct modulus;
 
struct modulus;
 
}}
 
}}
{{ddcl list end}}
+
{{
 +
 +
 +
 +
 +
end}}
  
{{tr|部門の剰余を計算するための関数オブジェクト。タイプ{{c|operator%}}用{{tt|T}}を実装しています.|Function object for computing remainders of divisions. Implements {{c|operator%}} for type {{tt|T}}.}}
+
{{tt|T}} {{c|operator%}}
  
===メンバータイプ===
+
======
{{dcl list begin}}
+
{{begin}}
{{dcl list hitem |{{tr| タイプ | Type }}| Definition }}
+
{{| |
{{dcl list item | {{tt|result_type}} | {{tt|T}}}}
+
{{tt|}} {{tt|}}
{{dcl list item | {{tt|first_argument_type}} | {{tt|T}} }}
+
}}
{{dcl list item | {{tt|second_argument_type}} | {{tt|T}} }}
+
{{| }}
{{dcl list end}}
+
{{}}
 +
}}
 +
{{}}
 +
 
 +
{{|T}}
  
 
===メンバ関数===
 
===メンバ関数===
{{dcl list begin}}
+
{{begin}}
{{dcl list mem fun | operator() | nolink=true |{{tr| 第二引数で最初の引数の除算の剰余を返します| returns the remainder from the division of the first argument by the second argument}}}}
+
{{mem fun | operator() | nolink=true | }}
{{dcl list end}}
+
{{end}}
  
{{member | {{small|{{tr|のstd ::モジュラス::|std::modulus::}}}}operator() | 2=
+
{{member | {{small|std::modulus::}}operator() | 2=
{{ddcl | 1=
+
{{
 +
 +
|=
 
T operator()( const T& lhs, const T& rhs ) const;
 
T operator()( const T& lhs, const T& rhs ) const;
 
}}
 
}}
 +
 +
 +
 +
 +
  
Returns the remainder of the division of {{tt|lhs}} by {{tt|rhs}}.
+
{{tt|lhs}} {{tt|rhs}}
  
===Parameters===
+
======
{{param list begin}}
+
{{begin}}
{{param list item | lhs, rhs |{{tr| 値を別つずつ分割する| values to divide one by another}}}}
+
{{| lhs, rhs | }}
{{param list end}}
+
{{end}}
  
===Return value===
+
======
The result of {{c|lhs % rhs}}.
+
{{c|lhs % rhs}}
  
===Exceptions===
+
======
(none)
+
()
  
===Possible implementation===
+
======
 
{{eq fun | 1=
 
{{eq fun | 1=
T operator()(const T &lhs, const T &rhs) const  
+
T operator()(const T &lhs, const T &rhs) const  
 
{
 
{
 
     return lhs % rhs;
 
     return lhs % rhs;
51行: 68行:
 
}}
 
}}
 
}}
 
}}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +

2018年6月10日 (日) 04:04時点における最新版

 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
関数オブジェクト
関数ラッパー
(C++11)
(C++11)
関数の部分適用
(C++20)
(C++11)
関数呼び出し
(C++17)
恒等関数オブジェクト
(C++20)
参照ラッパー
(C++11)(C++11)
演算子ラッパー
否定子
(C++17)
検索子
制約付き比較子
古いバインダとアダプタ
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
(C++17未満)(C++17未満)
(C++17未満)(C++17未満)

(C++17未満)
(C++17未満)(C++17未満)(C++17未満)(C++17未満)
(C++20未満)
(C++20未満)
 
ヘッダ <functional> で定義
template< class T >
struct modulus;
(C++14未満)
template< class T = void >
struct modulus;
(C++14以上)

除算の余りを計算するための関数オブジェクト。 T 型に対する operator% を実装します。

目次

[編集] 特殊化

標準ライブラリは T が指定されない場合の引数型と戻り値型を推定する std::modulus の特殊化を提供します。

引数と戻り値の型を推定する x % y を実装する関数オブジェクト
(クラステンプレートの特殊化) [edit]
(C++14以上)

メンバ型

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

[編集] メンバ関数

operator()
第1引数を第2引数で割った余りを返します
(パブリックメンバ関数)

std::modulus::operator()

T operator()( const T& lhs, const T& rhs ) const;
(C++14未満)
constexpr T operator()( const T& lhs, const T& rhs ) const;
(C++14以上)

lhsrhs で割った余りを返します。

引数

lhs, rhs - 除算する値

戻り値

lhs % rhs の結果。

例外

(なし)

実装例

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

[編集] 関連項目

(C++11)(C++11)
浮動小数点除算の余りを計算します
(関数) [edit]
(C++11)(C++11)(C++11)
除算の符号付きの余りを計算します
(関数) [edit]