是否所有扩展 std::is_floating_point 的类型都需要在 C++11 标准中实现 FENV?

Are all types extending std::is_floating_point required to implement FENV in C++11 standard?

我正在实现如下功能:

template <typename FP>
void do_something(FP f){
    static_assert(std::is_floating_point<FP>::value, "not a floating point");
    ...
}

在此上下文中,可以使用任何浮点数(本机或自定义,即多精度浮点库)。

我想知道标准是否说明了重载 is_floating_point 类型的预期结果。我可以算作他们被要求使用 FENV 吗?

如果自定义浮点实现重载 std::is_floating_point,我可以假设以下代码应该正常工作吗?

template <typename FP>
void do_something(FP f){
    static_assert(std::is_floating_point<FP>::value, "not a floating point");
    if (std::fetestexcept(FE_DIVBYZERO)){
        ...
    }
}

std::is_floating_point 而言,没有“自定义浮点类型”这样的东西。

20.10.4.1/1 The primary type categories correspond to the descriptions given in section 3.9 of the C++ standard.

Table 47 — Primary type category predicates template <class T> struct is_floating_point; T is a floating point type (3.9.1)

3.9.1/8 There are three floating point types: float, double, and long double.

17.6.4.2.1/1 The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type and the specialization meets the standard library requirements for the original template and is not explicitly prohibited.