r/cpp • • Aug 22 '25

The power of C++26 reflection: first class existentials

100 Upvotes

98 comments sorted by

View all comments

Show parent comment

6

u/kammce WG21 | πŸ‡ΊπŸ‡² NB | Boost | Exceptions Aug 22 '25

Fun fact, besides std::current_exception, which requires TLS, exceptions should work so long as you put noexcept on your thread functions (or wrap them), that way the unwinder knows to stop unwinding at the thread boundary. When I implement <thread> (with stack size hint) for FreeRTOS, it'll take care of all of the noexcept and TLS stuff for you so you get access to the current exception. And for those that don't want to use std::thread with a stack hint and name, I can do a write up for enabling TLS for exceptions for FreeRTOS. And if you use a different RTOS, then we can look into supporting them as well. So stay tuned. 😁

3

u/theICEBear_dk Aug 22 '25

I am using FreeRTOS and we are not using std::thread we have our own abstraction around FreeRTOS so a simple description or write up would be super helpful. And I will stay tuned -- do not worry about that -- because it will fall to me to implement it later on and the developers I support are really tired of writing:

if (auto result = some_object.some_call_that_returns_expected(); !result) {

//Error handling or return to higher up here

}