@@ -493,7 +493,7 @@ Format specifications for range types have the following syntax:
493
493
.. productionlist :: sf
494
494
range_format_spec: [":" [`n `][`range_type `][`range_underlying_spec `]]
495
495
496
- The `n ` option causes the range to be formatted without the opening and closing brackets.
496
+ The `n ` option formats the range without the opening and closing brackets.
497
497
498
498
The available presentation types for `range_type ` are:
499
499
@@ -509,7 +509,8 @@ The available presentation types for `range_type` are:
509
509
| | |
510
510
+---------+----------------------------------------------------------+
511
511
512
- If `range_type ` is `s ` or `?s `, the underlying type of the range must be a char type.
512
+ If `range_type ` is `s ` or `?s `, the underlying type of the range must be a character type. The
513
+ `n ` option and `range_underlying_spec ` are mutually exclusive with `s ` and `?s `.
513
514
514
515
The `underlying_spec ` is parsed based on the formatter of the range's
515
516
reference type.
@@ -526,6 +527,12 @@ Examples::
526
527
// Result: [0xa, 0x14, 0x1e]
527
528
fmt::format("{}", vector{'h', 'e', 'l', 'l', 'o'});
528
529
// Result: ['h', 'e', 'l', 'l', 'o']
530
+ fmt::format("{:n}", vector{'h', 'e', 'l', 'l', 'o'});
531
+ // Result: 'h', 'e', 'l', 'l', 'o'
532
+ fmt::format("{:s}", vector{'h', 'e', 'l', 'l', 'o'});
533
+ // Result: "hello"
534
+ fmt::format("{:?s}", vector{'h', 'e', 'l', 'l', 'o', '\n'});
535
+ // Result: "hello\n"
529
536
fmt::format("{::}", vector{'h', 'e', 'l', 'l', 'o'});
530
537
// Result: [h, e, l, l, o]
531
538
fmt::format("{::d}", vector{'h', 'e', 'l', 'l', 'o'});
0 commit comments