From Jason Turner

[format.context]

Diff to HTML by rtfpessoa

tmp/tmp52q91vpq/{from.md → to.md} RENAMED
@@ -10,11 +10,11 @@ namespace std {
10
  public:
11
  using iterator = Out;
12
  using char_type = charT;
13
  template<class T> using formatter_type = formatter<T, charT>;
14
 
15
- basic_format_arg<basic_format_context> arg(size_t id) const;
16
  std::locale locale();
17
 
18
  iterator out();
19
  void advance_to(iterator it);
20
  };
@@ -30,19 +30,18 @@ of the formatting arguments and the output iterator.
30
  `basic_format_context` with an output iterator that appends to `string`,
31
  such as `back_insert_iterator<string>`. Similarly, `wformat_context` is
32
  an alias for a specialization of `basic_format_context` with an output
33
  iterator that appends to `wstring`.
34
 
35
- [*Note 1*: For a given type `charT`, implementations are encouraged to
36
  provide a single instantiation of `basic_format_context` for appending
37
  to `basic_string<charT>`, `vector<charT>`, or any other container with
38
  contiguous storage by wrapping those in temporary objects with a uniform
39
- interface (such as a `span<charT>`) and polymorphic
40
- reallocation. — *end note*]
41
 
42
  ``` cpp
43
- basic_format_arg<basic_format_context> arg(size_t id) const;
44
  ```
45
 
46
  *Returns:* `args_.get(id)`.
47
 
48
  ``` cpp
@@ -54,17 +53,17 @@ takes one, and `std::locale()` otherwise.
54
 
55
  ``` cpp
56
  iterator out();
57
  ```
58
 
59
- *Returns:* `out_`.
60
 
61
  ``` cpp
62
  void advance_to(iterator it);
63
  ```
64
 
65
- *Effects:* Equivalent to: `out_ = it;`
66
 
67
  [*Example 1*:
68
 
69
  ``` cpp
70
  struct S { int value; };
@@ -86,11 +85,11 @@ template<> struct std::formatter<S> {
86
  ctx.check_arg_id(width_arg_id);
87
  return ++iter;
88
  }
89
 
90
  // Formats an S with width given by the argument width_arg_id.
91
- auto format(S s, format_context& ctx) {
92
  int width = visit_format_arg([](auto value) -> int {
93
  if constexpr (!is_integral_v<decltype(value)>)
94
  throw format_error("width is not integral");
95
  else if (value < 0 || value > numeric_limits<int>::max())
96
  throw format_error("invalid width");
 
10
  public:
11
  using iterator = Out;
12
  using char_type = charT;
13
  template<class T> using formatter_type = formatter<T, charT>;
14
 
15
+ basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
16
  std::locale locale();
17
 
18
  iterator out();
19
  void advance_to(iterator it);
20
  };
 
30
  `basic_format_context` with an output iterator that appends to `string`,
31
  such as `back_insert_iterator<string>`. Similarly, `wformat_context` is
32
  an alias for a specialization of `basic_format_context` with an output
33
  iterator that appends to `wstring`.
34
 
35
+ *Recommended practice:* For a given type `charT`, implementations should
36
  provide a single instantiation of `basic_format_context` for appending
37
  to `basic_string<charT>`, `vector<charT>`, or any other container with
38
  contiguous storage by wrapping those in temporary objects with a uniform
39
+ interface (such as a `span<charT>`) and polymorphic reallocation.
 
40
 
41
  ``` cpp
42
+ basic_format_arg<basic_format_context> arg(size_t id) const noexcept;
43
  ```
44
 
45
  *Returns:* `args_.get(id)`.
46
 
47
  ``` cpp
 
53
 
54
  ``` cpp
55
  iterator out();
56
  ```
57
 
58
+ *Effects:* Equivalent to: `return std::move(out_);`
59
 
60
  ``` cpp
61
  void advance_to(iterator it);
62
  ```
63
 
64
+ *Effects:* Equivalent to: `out_ = std::move(it);`
65
 
66
  [*Example 1*:
67
 
68
  ``` cpp
69
  struct S { int value; };
 
85
  ctx.check_arg_id(width_arg_id);
86
  return ++iter;
87
  }
88
 
89
  // Formats an S with width given by the argument width_arg_id.
90
+ auto format(S s, format_context& ctx) const {
91
  int width = visit_format_arg([](auto value) -> int {
92
  if constexpr (!is_integral_v<decltype(value)>)
93
  throw format_error("width is not integral");
94
  else if (value < 0 || value > numeric_limits<int>::max())
95
  throw format_error("invalid width");