3

Asynchronous functions often do not use exceptions.

Even on synchronous calls, Asio and Boost-Beast have overloads that take an output argument of type system_error& instead of throwing.

Asynchronous operations can't throw exceptions because the operation doesn't complete in the stack frame of the calling code¹.

Is there a technical reason why these are not declared noexcept?

Apart from possible performance advantages, I also think it would be useful as a hint for the user, because the user knows they don't need exception handling.

¹ technically, they might throw exceptions like on precondition checks or invalid arguments

sehe
  • 374,641
  • 47
  • 450
  • 633
Benjamin Buch
  • 4,752
  • 7
  • 28
  • 51
  • 6
    i think they've been around longer than `noexcept` has been. – Daniel A. White Feb 15 '18 at 13:14
  • @DanielA.White Well, I'm pretty sure `throw()` which is older brother of `noexcept` was there before `std::thread`. My guess it is just an oversight in a library. As said in question - they are not throwing anything anyway. – bartop Feb 15 '18 at 14:35
  • @bartop `throw()` was fraught with problems and lack adoption to the extent that nobody used it, and guidelines actively warned not to use it. – sehe Feb 16 '18 at 18:25

0 Answers0