-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
constexpr scope guards #5
Comments
Thanks @Morwenn, for your interesting observation. I'll try and incorporate it. |
martinmoene
added a commit
that referenced
this issue
Aug 17, 2022
Todo:
|
martinmoene
added a commit
that referenced
this issue
Aug 17, 2022
martinmoene
added a commit
that referenced
this issue
Aug 17, 2022
martinmoene
added a commit
that referenced
this issue
Aug 17, 2022
martinmoene
added a commit
that referenced
this issue
Aug 17, 2022
martinmoene
added a commit
that referenced
this issue
Aug 18, 2022
martinmoene
added a commit
that referenced
this issue
Aug 18, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, it occurred to me recently that it is easily possible to make scope guards
constexpr
in C++20 by makinguncaught_exceptions constexpr
itself. The following function should be very simple yet sufficient:At
constexpr
time, there shouldn't be any exception in flight at any moment sincethrow
terminates the compilation, therefore we can safely return0
, it will always be true.I know that basing scope guards on
uncaught_exceptions()
is fragile because of known issues with coroutines, but the proposed change is arguably rather useful, is a strict improvement to the existing implementation, and makes it work at compile-time, a context where it will correctly work even in the presence of coroutines.Anyway, thanks for the library :)
The text was updated successfully, but these errors were encountered: