-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove fallback to inline specifier from FMT_CONSTEXPR(20) macro #2075
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
Remove fallback to inline specifier from FMT_CONSTEXPR(20) macro #2075
Conversation
9e9a21f to
70ae54a
Compare
…e` specifiers in headers
…e` specifiers in tests
70ae54a to
f5e9b86
Compare
vitaut
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Mostly looks good, just a few minor comments inline =).
| template <> FMT_CONSTEXPR const char* get_units<std::peta>() { return "Ps"; } | ||
| template <> FMT_CONSTEXPR const char* get_units<std::exa>() { return "Es"; } | ||
| template <> FMT_CONSTEXPR const char* get_units<std::ratio<60>>() { | ||
| template <> FMT_CONSTEXPR inline const char* get_units<std::atto>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove inline from all these functions? Ideally all of this should be rewritten without template specializations but this is out of scope of the current PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It causes multiple definitions of these functions.
Maybe a test for multiple definitions can be added, which would include all headers in two object files and link them together. Because now I have to include chrono.h into util.h in the test directory to get this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I don't think the multiple definition test is necessary.
…d `inline` specifiers" This reverts commit f35325e
As it was discussed here - #2056 (comment), an fallback to the
inlineinsideFMT_CONSTEXPR(20)macro definitions is not always a good solution. Especially whenFMT_CONSTEXPR(20)macro should be used together withFMT_INLINEmacro, in C++11 they both expand toinlinespecifier.In this PR I removed that fallback to
inlineand placedinlinespecifiers where it's needed (for non-template, not member or friend defined in class/struct/union functions), so everything should stay the same in C++11. WhenFMT_CONSTEXPR(20)is expanded toconstexprall these manually-tuned functions will haveconstexpr inlinespecifiers, which is okay.