Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't N3421 provide the noexcept qualifier?

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));
};

instead of

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));
};
  • Is there a reason for that?
  • Does the omission of noexcept matter in this use case?

Edit: link to the working draft line in github.

Edit 2: link to libc++ plus specialization.

like image 513
gnzlbg Avatar asked Dec 26 '22 13:12

gnzlbg


1 Answers

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.

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.

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

like image 83
Puppy Avatar answered Feb 04 '23 03:02

Puppy