Namespaces
Variants

std:: divides<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 divides < void > ;
(C++14以降)

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

目次

翻訳のポイント: - 「Contents」→「目次」に翻訳 - C++固有の用語(Member types、Member functions、operator()、Parameters、Return value、Example)は原文のまま保持 - HTMLタグ、属性、クラス名は一切変更せず - 数値や記号はそのまま保持 - プロフェッショナルな技術文書としての正確性を維持

メンバー型

定義
is_transparent unspecified

メンバー関数

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

std::divides<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 <complex>
#include <functional>
#include <iostream>
int main()
{
    auto complex_divides = std::divides<void>{}; // 「void」は省略可能
    constexpr std::complex z1{8.0, 4.0}, z2{1.0, 2.0};
    std::cout << std::showpos
              << complex_divides(z1, z2) << ' ' << z1 / z2 << '\n'
              << complex_divides(z1, 5.) << ' ' << z1 / 5. << '\n'
              << complex_divides(6., z2) << ' ' << 6. / z2 << '\n';
}

出力:

(+3.2,-2.4) (+3.2,-2.4)
(+1.6,+0.8) (+1.6,+0.8)
(+1.2,-2.4) (+1.2,-2.4)