-
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
Reenable support for fallback formatter to join (#2040) #2050
Conversation
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.
include/fmt/ostream.h
Outdated
@@ -147,6 +147,19 @@ struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>> | |||
return std::copy(buffer.begin(), buffer.end(), ctx.out()); | |||
} | |||
}; | |||
|
|||
template <typename It, typename Sentinel, typename Char> | |||
struct fallback_formatter<arg_join<It, Sentinel, Char>, Char> |
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.
fallback_formatter
is not an extension point so it shouldn't be specialize for arg_join
. Instead make formatter
specialization enabled if there is a fallback formatter for the element type as it is done for ranges.
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.
Ok hope it is better now.
742abd6
to
ca5414c
Compare
include/fmt/format.h
Outdated
: formatter<typename std::iterator_traits<It>::value_type, Char> { | ||
struct formatter<arg_join<It, Sentinel, Char>, Char> { | ||
using value_type = typename std::iterator_traits<It>::value_type; | ||
using context_type = basic_format_context<arg_join<It, Sentinel, Char>, Char>; |
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.
This is not needed.
include/fmt/format.h
Outdated
using context_type = basic_format_context<arg_join<It, Sentinel, Char>, Char>; | ||
using formatter_type = | ||
conditional_t<has_formatter<value_type, format_context>::value, | ||
typename context_type::template formatter_type<value_type>, |
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.
Just use formatter<value_type, Char>
here.
include/fmt/format.h
Outdated
using value_type = typename std::iterator_traits<It>::value_type; | ||
using context_type = basic_format_context<arg_join<It, Sentinel, Char>, Char>; | ||
using formatter_type = | ||
conditional_t<has_formatter<value_type, format_context>::value, | ||
typename context_type::template formatter_type<value_type>, | ||
detail::fallback_formatter<value_type, Char>>; | ||
|
||
formatter_type formatting; |
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.
These should be private.
ca5414c
to
94383a5
Compare
94383a5
to
34c404c
Compare
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.
Looks good, just one more comment.
34c404c
to
6d9892f
Compare
Merged, thanks. |
Thanks for your time and what you have done so far. It is really great! |
I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.