Skip to content
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

Convert BUG macros to constexpr variadic functions for better typing. #3774

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

fruffy-bfn
Copy link
Contributor

WiP.

lib/exceptions.h Outdated
} // namespace Util

template <class... Args>
[[noreturn]] inline auto BUG(Args&&... args) {
throw Util::CompilerBug(__LINE__, __FILE__, std::forward<Args>(args)...);
Copy link

@vhavel vhavel Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this alter the meaning of __LINE__ and __FILE__?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and that is why C++20 adds std::source_location:
https://en.cppreference.com/w/cpp/utility/source_location

That is only there for C++20 and not in C++17 mode for GCC.

Copy link
Contributor Author

@fruffy-bfn fruffy-bfn Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will not work with C++17 I believe. I was just getting annoyed with warnings about the BUG macros, so I wrote up this draft. Once we switch to C++20, this might be something worth considering.

This new syntax is horrid, though.

@fruffy-bfn fruffy-bfn force-pushed the exception_typing branch 3 times, most recently from a65b46c to 517bb52 Compare December 12, 2022 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants