为什么N3421不提供noexcept限定符? [英] Why doesn't N3421 provide the noexcept qualifier?

查看:236
本文介绍了为什么N3421不提供noexcept限定符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

N3421 - 使操作符更大<> ,std函数对象的新特化是:

In N3421 - Making Operator Functors greater<>, the new specialization for the std function objects is:

template <> struct plus<void> {
  template <class T, class U> auto operator()(T&& t, U&& u) const
  -> decltype(std::forward<T>(t) + std::forward<U>(u));
};

而不是

template <> struct plus<void> {
  template <class T, class U> auto operator()(T&& t, U&& u) const
  noexcept(noexcept(decltype(std::forward<T>(t) + std::forward<U>(u))
                     (std::move(std::forward<T>(t) + std::forward<U>(u)))))
  -> decltype(std::forward<T>(t) + std::forward<U>(u));
};




  • 有理由吗?

  • noexcept 的遗漏在此用例中是否重要?

    • Is there a reason for that?
    • Does the omission of noexcept matter in this use case?
    • 编辑:链接到工作草稿

      link to the working draft line in github.

      编辑2: libc ++ plus specialization的链接

      推荐答案

      不鼓励使用noexcept。他们不接受广泛合同职能的noexcept,只有狭义合同职能。我不记得这些术语是如何定义的,但我可以告诉你,我在布里斯托会议上讨论 noexcept ,他们拒绝将它放在一个函数,因为它是广泛合同,我认为是batshit疯狂。

      The existing LWG guidelines do not encourage the use of noexcept. They do not accept noexcept on wide-contract functions, only narrow-contract ones. I don't recall exactly how these terms were defined, but I can tell you that I was present at the Bristol meeting discussing noexcept and they refused to place it on a function because it was wide-contract, which I considered to be batshit insane.

      所以这可能不是在这里有两个原因之一。第一个是,委员会和论文作者尚未习惯在每种情况下考虑 noexcept - 类似于 constexpr 。在这种情况下,论文作者(STL)可能只是忘了添加它。

      So it's probably not on here for one of two reasons. The first is that the Committee and paper authors are not yet used to considering noexcept in every case- similar to constexpr. In this case, the paper author (STL) probably simply forgot to add it.

      第二个是LWG有一些疯狂的过度限制,当他们将接受 noexcept

      The second is that LWG has some insane over-restrictions on when they will accept noexcept.

      这篇关于为什么N3421不提供noexcept限定符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆