Extending fmt::join to support C++20-only ranges. (#2549)
This commit is contained in:
+10
-3
@@ -2748,7 +2748,12 @@ using arg_join FMT_DEPRECATED_ALIAS = join_view<It, Sentinel, Char>;
|
||||
template <typename It, typename Sentinel, typename Char>
|
||||
struct formatter<join_view<It, Sentinel, Char>, Char> {
|
||||
private:
|
||||
using value_type = typename std::iterator_traits<It>::value_type;
|
||||
using value_type =
|
||||
#ifdef __cpp_lib_ranges
|
||||
std::iter_value_t<It>;
|
||||
#else
|
||||
typename std::iterator_traits<It>::value_type;
|
||||
#endif
|
||||
using context = buffer_context<Char>;
|
||||
using mapper = detail::arg_mapper<context>;
|
||||
|
||||
@@ -2782,11 +2787,13 @@ struct formatter<join_view<It, Sentinel, Char>, Char> {
|
||||
auto it = value.begin;
|
||||
auto out = ctx.out();
|
||||
if (it != value.end) {
|
||||
out = value_formatter_.format(map(*it++), ctx);
|
||||
out = value_formatter_.format(map(*it), ctx);
|
||||
++it;
|
||||
while (it != value.end) {
|
||||
out = detail::copy_str<Char>(value.sep.begin(), value.sep.end(), out);
|
||||
ctx.advance_to(out);
|
||||
out = value_formatter_.format(map(*it++), ctx);
|
||||
out = value_formatter_.format(map(*it), ctx);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
||||
Reference in New Issue
Block a user