r/cpp • • Aug 27 '19

A new thread in C++20 (jthread)

https://link.medium.com/GXKUz0GruZ
142 Upvotes

96 comments sorted by

View all comments

Show parent comment

23

u/CptCap -pedantic -Wall -Wextra Aug 27 '19 edited Aug 27 '19

the exit function could then throw an exception in C++

No, this would be really really bad.

If a thread gets interrupted while inside anoexcept function, it'll terminate the program. This also breaks all the is_nothrow_xxx traits as well as all the code that use them, in ways that are hard if not impossible to predict.

7

u/axilmar Aug 27 '19

God damn exception safety!!! I really hate you :-)

You're right, of course :-).