Added formatter for bit_reference-like types - #3570
Merged
Merged
Conversation
phprus
marked this pull request as draft
August 4, 2023 19:44
phprus
marked this pull request as ready for review
August 4, 2023 20:18
phprus
marked this pull request as draft
August 4, 2023 20:21
phprus
marked this pull request as ready for review
August 4, 2023 21:02
Contributor
Author
|
Final version. |
wangzw
reviewed
Aug 5, 2023
phprus
marked this pull request as draft
August 5, 2023 08:29
Contributor
Author
|
Final-2 version :) |
phprus
marked this pull request as ready for review
August 5, 2023 09:46
wangzw
reviewed
Aug 5, 2023
wangzw
reviewed
Aug 5, 2023
vitaut
requested changes
Aug 5, 2023
vitaut
left a comment
Contributor
There was a problem hiding this comment.
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>
Contributor
Author
|
@vitaut |
Contributor
|
Works well for me. Thanks |
vitaut
reviewed
Aug 6, 2023
vitaut
reviewed
Aug 6, 2023
vitaut
reviewed
Aug 6, 2023
vitaut
reviewed
Aug 6, 2023
vitaut
reviewed
Aug 6, 2023
Comment on lines
+424
to
+438
| #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 |
Contributor
There was a problem hiding this comment.
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).
…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>
vitaut
approved these changes
Aug 6, 2023
Contributor
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for issue #3567
Test is based on #3569