C++ 23 · Input, exceptions and threads
Handle exceptions
Catch exceptions by const reference.
try {
auto n = std::stoi(text);
} catch (const std::exception& e) {
std::cerr << e.what() << '\n';
}
More input, exceptions and threads commands
- Read a file line by line
- Read a line from the keyboard
- Run code on another thread
- Compute a value in the background
- Share a counter between threads
- Time a section of code
All input, exceptions and threads commands · C++ 23 cheatsheet