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

c – 类模板部分特化中是否允许noexcept演绎?,第1张

概述对于下面的程序,Clang 5(主干)报告IsNoexcept不可推导,而GCC 7.1段错误.标准(草案)对此有何评论?这是编译器的QOI问题吗? static_assert(__cpp_noexcept_function_type, "requires c++1z");template<typename T>struct is_noexcept;template<bool IsNoe 对于下面的程序,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() {}

与提案P0012有关.

解决方法 > [temp.deduct.type]/8列出了可以推导出模板参数的所有类型的类型.异常规范不在列表中,因此不可推断.
>作为 an extension,GCC允许从noexcept中推导出来以简化std :: is_function的实现.看起来扩展只是非常轻微的测试.
>这个扩展最初是由Clang的维护者提出的,似乎在委员会中有一些支持,但是 it’s not clear if it will eventually make its way into the standard.
>这不是一个符合标准的扩展,因为它改变了明确定义的代码的含义,例如g(f)的值与下面的代码片段:
voID f() noexcept;template<bool E = false,class R>constexpr bool g(R (*)() noexcept(E)){    return E;}
总结

以上是内存溢出为你收集整理的c – 类模板部分特化中是否允许noexcept演绎?全部内容,希望文章能够帮你解决c – 类模板部分特化中是否允许noexcept演绎?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1240708.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存