-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support printing (const) volatile void* #4056
Conversation
13860e8
to
63fb57c
Compare
test/base-test.cc
Outdated
auto check = [](const int val) { | ||
CHECK_ARG( | ||
char, reinterpret_cast<const void*>(val), | ||
static_cast<volatile void*>(reinterpret_cast<volatile int*>(val))); | ||
CHECK_ARG(char, reinterpret_cast<const void*>(val), | ||
static_cast<const volatile void*>( | ||
reinterpret_cast<const volatile int*>(val))); | ||
}; | ||
check(0); | ||
check(1); | ||
check(2); | ||
check(0xbeef); |
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 don't think we need to check various values here, let's get rid of the lambda and just check nullptr.
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 was just being safe to cover the behaviour with iostreams linked in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1147r1.html but if you're happy for it to be removed I'll take it out
63fb57c
to
cc5e38f
Compare
cc5e38f
to
5e7b6a4
Compare
Merged, thanks! |
why 4 overloads instead of 1 overload taking a const volatile void*? |
It's a good question. If all we had was 4 overloaded functions ( However, there's also this: Lines 1487 to 1498 in 6a192f8
as we only want to format (const)? (volatile)? void pointers, so this catches other pointer types to render them unformattable. If we remove the first 3 of those, leaving only the It will then go and instantiate the See https://godbolt.org/z/3cTj5xErM and flip the define You could probably get this working with some SFINAE (although I think you'll have a similar issue with getting |
making the SFINAE condition
will work. I agree that overloading is easier to reason about. but I just wanted to point it out. |
@ZXShady Good point, the SFINAE isn't so bad actually. Also I've learnt something from your comment, as I didn't know realise that all types of |
- Update from version 11.0.1 to 11.0.2 - Update of rootfile - Changelog 11.0.2 - Fixed compatibility with non-POSIX systems (fmtlib/fmt#4054, fmtlib/fmt#4060). - Fixed performance regressions when using `std::back_insert_iterator` with `fmt::format_to` (fmtlib/fmt#4070). - Fixed handling of `std::generator` and move-only iterators (fmtlib/fmt#4053, fmtlib/fmt#4057). Thanks @Arghnews. - Made `formatter<std::string_view>::parse` work with types convertible to `std::string_view` (fmtlib/fmt#4036, fmtlib/fmt#4055). Thanks @Arghnews. - Made `volatile void*` formattable (fmtlib/fmt#4049, fmtlib/fmt#4056). Thanks @Arghnews. - Made `Glib::ustring` not be confused with `std::string` (fmtlib/fmt#4052). - Made `fmt::context` iterator compatible with STL algorithms that rely on iterator category (fmtlib/fmt#4079). Signed-off-by: Adolf Belka <[email protected]> Signed-off-by: Michael Tremer <[email protected]>
Fixes #4049