From Jason Turner

[charconv]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp6jh1f6sg/{from.md → to.md} +22 -23
tmp/tmp6jh1f6sg/{from.md → to.md} RENAMED
@@ -1,61 +1,60 @@
1
  ## Primitive numeric conversions <a id="charconv">[[charconv]]</a>
2
 
3
  ### Header `<charconv>` synopsis <a id="charconv.syn">[[charconv.syn]]</a>
4
 
5
  When a function is specified with a type placeholder of `integer-type`,
6
- the implementation provides overloads for all cv-unqualified signed and
7
- unsigned integer types and `char` in lieu of `integer-type`. When a
8
  function is specified with a type placeholder of `floating-point-type`,
9
  the implementation provides overloads for all cv-unqualified
10
  floating-point types [[basic.fundamental]] in lieu of
11
  `floating-point-type`.
12
 
13
  ``` cpp
14
- %
15
- %
16
- {chars_format{chars_format{chars_format{chars_formatnamespace std {
17
  // floating-point format for primitive numerical conversion
18
  enum class chars_format {
19
  scientific = unspecified,
20
  fixed = unspecified,
21
  hex = unspecified,
22
  general = fixed | scientific
23
  };
24
- %
25
- %
26
- {to_chars_result{to_chars_result}
27
 
28
  // [charconv.to.chars], primitive numerical output conversion
29
- struct to_chars_result {
30
  char* ptr;
31
  errc ec;
32
  friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
 
33
  };
34
 
35
- constexpr to_chars_result to_chars(char* first, char* last, integer-type value, int base = 10);
36
- to_chars_result to_chars(char* first, char* last, bool value, int base = 10) = delete;
 
 
37
 
38
- to_chars_result to_chars(char* first, char* last, floating-point-type value);
39
- to_chars_result to_chars(char* first, char* last, floating-point-type value, chars_format fmt);
40
- to_chars_result to_chars(char* first, char* last, floating-point-type value,
41
- chars_format fmt, int precision);
42
- %
43
- %
44
- {from_chars_result{from_chars_result}
45
 
46
  // [charconv.from.chars], primitive numerical input conversion
47
- struct from_chars_result {
48
  const char* ptr;
49
  errc ec;
50
  friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
 
51
  };
52
 
53
- constexpr from_chars_result from_chars(const char* first, const char* last,
54
  integer-type& value, int base = 10);
55
 
56
- from_chars_result from_chars(const char* first, const char* last, floating-point-type& value,
 
57
  chars_format fmt = chars_format::general);
58
  }
59
  ```
60
 
61
  The type `chars_format` is a bitmask type [[bitmask.types]] with
@@ -145,11 +144,11 @@ to_chars_result to_chars(char* first, char* last, floating-point-type value,
145
  *Effects:* `value` is converted to a string in the style of `printf` in
146
  the `"C"` locale with the given precision.
147
 
148
  *Throws:* Nothing.
149
 
150
- See also: ISO C 7.21.6.1
151
 
152
  ### Primitive numeric input conversion <a id="charconv.from.chars">[[charconv.from.chars]]</a>
153
 
154
  All functions named `from_chars` analyze the string \[`first`, `last`)
155
  for a pattern, where \[`first`, `last`) is required to be a valid range.
@@ -211,7 +210,7 @@ the `"C"` locale, as described for `strtod`, except that
211
  In any case, the resulting `value` is one of at most two floating-point
212
  values closest to the value of the string matching the pattern.
213
 
214
  *Throws:* Nothing.
215
 
216
- See also: ISO C 7.22.1.3, 7.22.1.4
217
 
 
1
  ## Primitive numeric conversions <a id="charconv">[[charconv]]</a>
2
 
3
  ### Header `<charconv>` synopsis <a id="charconv.syn">[[charconv.syn]]</a>
4
 
5
  When a function is specified with a type placeholder of `integer-type`,
6
+ the implementation provides overloads for `char` and all cv-unqualified
7
+ signed and unsigned integer types in lieu of `integer-type`. When a
8
  function is specified with a type placeholder of `floating-point-type`,
9
  the implementation provides overloads for all cv-unqualified
10
  floating-point types [[basic.fundamental]] in lieu of
11
  `floating-point-type`.
12
 
13
  ``` cpp
14
+ namespace std {
 
 
15
  // floating-point format for primitive numerical conversion
16
  enum class chars_format {
17
  scientific = unspecified,
18
  fixed = unspecified,
19
  hex = unspecified,
20
  general = fixed | scientific
21
  };
 
 
 
22
 
23
  // [charconv.to.chars], primitive numerical output conversion
24
+ struct to_chars_result { // freestanding
25
  char* ptr;
26
  errc ec;
27
  friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
28
+ constexpr explicit operator bool() const noexcept { return ec == errc{}; }
29
  };
30
 
31
+ constexpr to_chars_result to_chars(char* first, char* last, // freestanding
32
+ integer-type value, int base = 10);
33
+ to_chars_result to_chars(char* first, char* last, // freestanding
34
+ bool value, int base = 10) = delete;
35
 
36
+ to_chars_result to_chars(char* first, char* last, // freestanding-deleted
37
+ floating-point-type value);
38
+ to_chars_result to_chars(char* first, char* last, // freestanding-deleted
39
+ floating-point-type value, chars_format fmt);
40
+ to_chars_result to_chars(char* first, char* last, // freestanding-deleted
41
+ floating-point-type value, chars_format fmt, int precision);
 
42
 
43
  // [charconv.from.chars], primitive numerical input conversion
44
+ struct from_chars_result { // freestanding
45
  const char* ptr;
46
  errc ec;
47
  friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
48
+ constexpr explicit operator bool() const noexcept { return ec == errc{}; }
49
  };
50
 
51
+ constexpr from_chars_result from_chars(const char* first, const char* last, // freestanding
52
  integer-type& value, int base = 10);
53
 
54
+ from_chars_result from_chars(const char* first, const char* last, // freestanding-deleted
55
+ floating-point-type& value,
56
  chars_format fmt = chars_format::general);
57
  }
58
  ```
59
 
60
  The type `chars_format` is a bitmask type [[bitmask.types]] with
 
144
  *Effects:* `value` is converted to a string in the style of `printf` in
145
  the `"C"` locale with the given precision.
146
 
147
  *Throws:* Nothing.
148
 
149
+ See also: ISO C 7.23.6.2
150
 
151
  ### Primitive numeric input conversion <a id="charconv.from.chars">[[charconv.from.chars]]</a>
152
 
153
  All functions named `from_chars` analyze the string \[`first`, `last`)
154
  for a pattern, where \[`first`, `last`) is required to be a valid range.
 
210
  In any case, the resulting `value` is one of at most two floating-point
211
  values closest to the value of the string matching the pattern.
212
 
213
  *Throws:* Nothing.
214
 
215
+ See also: ISO C 7.24.2.6, 7.24.2.8
216