@@ -388,7 +388,6 @@ struct range_formatter<
388
388
detail::string_literal<Char, ' [' >{};
389
389
basic_string_view<Char> closing_bracket_ =
390
390
detail::string_literal<Char, ' ]' >{};
391
- bool is_string_format = false ;
392
391
bool is_debug = false ;
393
392
394
393
public:
@@ -413,9 +412,7 @@ struct range_formatter<
413
412
auto it = ctx.begin ();
414
413
auto end = ctx.end ();
415
414
detail::maybe_set_debug_format (underlying_, true );
416
- if (it == end) {
417
- return underlying_.parse (ctx);
418
- }
415
+ if (it == end) return underlying_.parse (ctx);
419
416
420
417
switch (detail::to_ascii (*it)) {
421
418
case ' n' :
@@ -426,21 +423,17 @@ struct range_formatter<
426
423
is_debug = true ;
427
424
set_brackets ({}, {});
428
425
++it;
429
- if (it == end || *it != ' s' ) {
430
- report_error (" invalid format specifier" );
431
- }
426
+ if (it == end || *it != ' s' ) report_error (" invalid format specifier" );
432
427
FMT_FALLTHROUGH;
433
428
case ' s' :
434
- if (!std::is_same<T, Char>::value) {
429
+ if (!std::is_same<T, Char>::value)
435
430
report_error (" invalid format specifier" );
436
- }
437
431
if (!is_debug) {
438
432
set_brackets (detail::string_literal<Char, ' "' >{},
439
433
detail::string_literal<Char, ' "' >{});
440
434
set_separator ({});
441
435
detail::maybe_set_debug_format (underlying_, false );
442
436
}
443
- is_string_format = true ;
444
437
++it;
445
438
return it;
446
439
}
@@ -455,21 +448,19 @@ struct range_formatter<
455
448
return underlying_.parse (ctx);
456
449
}
457
450
458
- template <typename Output, typename Iter , typename IterEnd , typename U = T,
451
+ template <typename Output, typename It , typename Sentinel , typename U = T,
459
452
FMT_ENABLE_IF (std::is_same<U, Char>::value)>
460
- auto write_debug_string (Output& out, Iter& it, IterEnd& end) const -> Output {
453
+ auto write_debug_string (Output& out, It it, Sentinel end) const -> Output {
461
454
auto buf = basic_memory_buffer<Char>();
462
- for (; it != end; ++it) {
463
- buf.push_back (*it);
464
- }
465
- format_specs spec_str;
466
- spec_str.type = presentation_type::debug;
455
+ for (; it != end; ++it) buf.push_back (*it);
456
+ auto specs = format_specs ();
457
+ specs.type = presentation_type::debug;
467
458
return detail::write <Char>(
468
- out, basic_string_view<Char>(buf.data (), buf.size ()), spec_str );
459
+ out, basic_string_view<Char>(buf.data (), buf.size ()), specs );
469
460
}
470
- template <typename Output, typename Iter , typename IterEnd , typename U = T,
461
+ template <typename Output, typename It , typename Sentinel , typename U = T,
471
462
FMT_ENABLE_IF (!std::is_same<U, Char>::value)>
472
- auto write_debug_string (Output& out, Iter&, IterEnd& ) const -> Output {
463
+ auto write_debug_string (Output& out, It, Sentinel ) const -> Output {
473
464
return out;
474
465
}
475
466
@@ -479,17 +470,14 @@ struct range_formatter<
479
470
auto out = ctx.out ();
480
471
auto it = detail::range_begin (range);
481
472
auto end = detail::range_end (range);
482
- if (is_debug) {
483
- return write_debug_string (out, it, end);
484
- }
473
+ if (is_debug) return write_debug_string (out, it, end);
485
474
486
475
out = detail::copy<Char>(opening_bracket_, out);
487
476
int i = 0 ;
488
477
for (; it != end; ++it) {
489
478
if (i > 0 ) out = detail::copy<Char>(separator_, out);
490
479
ctx.advance_to (out);
491
- auto && item = *it;
492
- out = underlying_.format (mapper.map (item), ctx);
480
+ out = underlying_.format (mapper.map (*it), ctx);
493
481
++i;
494
482
}
495
483
out = detail::copy<Char>(closing_bracket_, out);
0 commit comments