update fmt::join to support more character types#4686
Open
Yancey2023 wants to merge 3 commits intofmtlib:masterfrom
Open
update fmt::join to support more character types#4686Yancey2023 wants to merge 3 commits intofmtlib:masterfrom
Yancey2023 wants to merge 3 commits intofmtlib:masterfrom
Conversation
vitaut
requested changes
Feb 28, 2026
| // A loop is faster than memcpy on small sizes. | ||
| T* out = ptr_ + size; | ||
| for (size_t i = 0; i < count; ++i) out[i] = begin[i]; | ||
| for (size_t i = 0; i < count; ++i) out[i] = static_cast<T>(begin[i]); |
Contributor
There was a problem hiding this comment.
This cast shouldn't be here because we shouldn't mix different code units.
Author
There was a problem hiding this comment.
How can I fix the issues mentioned in my PR if I don't do this?
| template <typename Char> constexpr auto getsign(sign s) -> Char { | ||
| return static_cast<char>(((' ' << 24) | ('+' << 16) | ('-' << 8)) >> | ||
| (static_cast<int>(s) * 8)); | ||
| return static_cast<Char>(static_cast<char>( |
Contributor
There was a problem hiding this comment.
Won't one cast be sufficient?
Author
There was a problem hiding this comment.
This does need to cast twice.
int -> char -> wchar_t
I have try to cast to wchar_t directly, but the result is error.
Comment on lines
+162
to
+169
| template <typename T, typename S, | ||
| typename Char = typename decltype(detail::to_string_view( | ||
| std::declval<S>()))::value_type, | ||
| FMT_ENABLE_IF(detail::is_exotic_char<Char>::value)> | ||
| auto join(std::initializer_list<T> list, S&& sep) | ||
| -> join_view<const T*, const T*, Char> { | ||
| return {std::begin(list), std::end(list), detail::to_string_view(sep)}; | ||
| } |
Contributor
There was a problem hiding this comment.
This one is a questionable API and we should probably deprecated it. At the very least let's not touch it here.
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.
This PR brings more character type support for
fmt::join.Besides, implicit conversions of different character types may generate errors, so CI cannot pass. I also fix it.