I am thinking that why the second one can throw error.
@Acer it doesnt actually show you how to throw an exception in the second one. The comment just tells you it does (and references an example of a function which is known to throw system_error).
The function definition in CPP would never indicate directly that it can throw errors. You simply throw the error by calling "throw" inside the function when you write it to make the function throw an error.
@Acer It’s an explicit constructor for std::thread
, that starts a thread that runs f(args...)
.
@Acer it is saying it is better to throw an error to report problems then it is to use the return type to encode issues.