类模板部分特化是否允许noexcept演绎?

Bar*_*air 8 c++ type-traits language-lawyer c++17

对于下面的程序,Clang 5(主干)报告IsNoexcept不可扣除,而GCC 7.1段错误.标准(草案)对此有何评论?这是编译器QOI问题吗?

static_assert(__cpp_noexcept_function_type, "requires c++1z");

template<typename T>
struct is_noexcept;

template<bool IsNoexcept>
struct is_noexcept<void() noexcept(IsNoexcept)> {
    static constexpr auto value = IsNoexcept;
};

static_assert(is_noexcept<void() noexcept>::value);
static_assert(!is_noexcept<void()>::value);

int main() {}
Run Code Online (Sandbox Code Playgroud)

与提案P0012有关.

T.C*_*.C. 5

  1. [temp.deduct.type] / 8列出了可以推导出模板参数的所有类型的类型。在异常规范是不在列表中,因此不能推断出。
  2. 作为扩展,GCC允许noexcept简化的实施std::is_function。似乎该扩展程序仅经过了非常轻松的测试。
  3. 该扩展最初是由Clang的维护者提出的,似乎在委员会中得到了一些支持,但是目前尚不清楚它是否最终会成为标准
  4. 这不是一致的扩展,因为它更改了定义良好的代码的含义,例如,g(f)带有以下代码段的值:

    void f() noexcept;
    
    template<bool E = false, class R>
    constexpr bool g(R (*)() noexcept(E)){
        return E;
    }
    
    Run Code Online (Sandbox Code Playgroud)