相关疑难解决方法(0)

为什么N3421不提供noexcept限定符?

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

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));
};
Run Code Online (Sandbox Code Playgroud)

代替

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));
};
Run Code Online (Sandbox Code Playgroud)
  • 这有什么理由吗?
  • noexcept在这个用例中是否遗漏了问题?

编辑:链接到github中的工作草稿行.

编辑2:链接到libc ++ plus specialization.

c++ function-object c++-standard-library c++14

4
推荐指数
1
解决办法
403
查看次数