-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Added formatter for bit_reference-like types #3570
Conversation
Final version. |
Final-2 version :) |
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.
This looks like a lot of effort and implementation-specific code for such a corner case. I suggest just using std::addressoff and replacing FMT_CONSTEXPR with FMT_COSTEXPR20 in the value ctor overload that uses it. It only affects compile-time formatting anyway that requires a recent standard.
Co-authored-by: Felix <felix-antoine.constantin@polymtl.ca> Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
@vitaut |
Works well for me. Thanks |
include/fmt/std.h
Outdated
#ifdef _LIBCPP_VERSION | ||
|
||
// Workaround for libc++ incompatibility with C++ standard. | ||
// According to the Standard, `bitset::operator[] const` returns bool. | ||
FMT_EXPORT | ||
template <typename C, typename Char> | ||
struct formatter<std::__bit_const_reference<C>, Char> : formatter<bool, Char> { | ||
template <typename FormatContext> | ||
FMT_CONSTEXPR20 auto format(const std::__bit_const_reference<C>& v, | ||
FormatContext& ctx) const -> decltype(ctx.out()) { | ||
return formatter<bool, Char>::format(v, ctx); | ||
} | ||
}; | ||
|
||
#endif |
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.
I think this can be replaced by a specialization of is_bit_reference_like
for __bit_const_reference
which seems a bit cleaner (no duplicate formatter).
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.
Done.
…ol>::reference Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
Thank you! |
Fix for issue #3567
Test is based on #3569