Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
js324 committed Mar 22, 2024
1 parent c3c38f4 commit fe0a6b7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions doc/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Format specifications for range types have the following syntax:
.. productionlist:: sf
range_format_spec: [":" [`n`][`range_type`][`range_underlying_spec`]]

The `n` option causes the range to be formatted without the opening and closing brackets.
The `n` option formats the range without the opening and closing brackets.

The available presentation types for `range_type` are:

Expand All @@ -509,7 +509,8 @@ The available presentation types for `range_type` are:
| | |
+---------+----------------------------------------------------------+

If `range_type` is `s` or `?s`, the underlying type of the range must be a char type.
If `range_type` is `s` or `?s`, the underlying type of the range must be a character type. The
`n` option and `range_underlying_spec` are mutually exclusive with `s` and `?s`.

The `underlying_spec` is parsed based on the formatter of the range's
reference type.
Expand All @@ -526,6 +527,12 @@ Examples::
// Result: [0xa, 0x14, 0x1e]
fmt::format("{}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: ['h', 'e', 'l', 'l', 'o']
fmt::format("{:n}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: 'h', 'e', 'l', 'l', 'o'
fmt::format("{:s}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: "hello"
fmt::format("{:?s}", vector{'h', 'e', 'l', 'l', 'o', '\n'});
// Result: "hello\n"
fmt::format("{::}", vector{'h', 'e', 'l', 'l', 'o'});
// Result: [h, e, l, l, o]
fmt::format("{::d}", vector{'h', 'e', 'l', 'l', 'o'});
Expand Down

0 comments on commit fe0a6b7

Please sign in to comment.