std::divides_C++中文网

定义于头文件 <functional>

template< class T >
struct divides;

(C++14 前)

template< class T = void >
struct divides;

(C++14 起)

进行除法的函数对象。等效地调用二个 T 类型实例上的 operator/

特化

标准库提供 std::divides 在未指定 T 时的特化,使参数类型和返回类型留待推导。

(C++14 起)

成员类型

 
类型 定义
result_type(C++17 中弃用) T
first_argument_type(C++17 中弃用) T
second_argument_type(C++17 中弃用) T
(C++20 前)

成员函数

返回首参数除以第二参数的结果
(公开成员函数)

std::divides::operator()

T operator()( const T& lhs, const T& rhs ) const;

(C++14 前)

constexpr T operator()( const T& lhs, const T& rhs ) const;

(C++14 起)

返回 lhs 除以 rhs 的结果。

参数

返回值

lhs / rhs 的结果。

异常

(无)

可能的实现

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