名稱空間
變體
操作

std::divides<void>

來自 cppreference.com
 
 
 
函式物件
函式呼叫
(C++17)(C++23)
恆等函式物件
(C++20)
透明運算子包裝器
(C++14)
(C++14)
(C++14)
(C++14)  
divides<>
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

舊繫結器和介面卡
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)  
(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
(直到 C++17*)(直到 C++17*)
(直到 C++17*)(直到 C++17*)

(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
 
定義於標頭檔案 <functional>
template<>
class divides<void>;
(C++14 起)

std::divides<void>std::divides 的特化,其引數和返回型別是推導的。

目錄

[編輯] 成員型別

型別 定義
is_transparent 未指定

[編輯] 成員函式

operator()
返回兩個引數的商
(公開成員函式)

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));

返回 lhsrhs 的商。

引數

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” can be omitted
    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)