From Jason Turner

[utility.to.chars]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp08uyan4e/{from.md → to.md} +0 -90
tmp/tmp08uyan4e/{from.md → to.md} RENAMED
@@ -1,90 +0,0 @@
1
- ### Primitive numeric output conversion <a id="utility.to.chars">[[utility.to.chars]]</a>
2
-
3
- All functions named `to_chars` convert `value` into a character string
4
- by successively filling the range \[`first`, `last`), where \[`first`,
5
- `last`) is required to be a valid range. If the member `ec` of the
6
- return value is such that the value, when converted to `bool`, is
7
- `false`, the conversion was successful and the member `ptr` is the
8
- one-past-the-end pointer of the characters written. Otherwise, the
9
- member `ec` has the value `errc::value_too_large`, the member `ptr` has
10
- the value `last`, and the contents of the range \[`first`, `last`) are
11
- unspecified.
12
-
13
- The functions that take a floating-point `value` but not a `precision`
14
- parameter ensure that the string representation consists of the smallest
15
- number of characters such that there is at least one digit before the
16
- radix point (if present) and parsing the representation using the
17
- corresponding `from_chars` function recovers `value` exactly.
18
-
19
- [*Note 1*: This guarantee applies only if `to_chars` and `from_chars`
20
- are executed on the same implementation. — *end note*]
21
-
22
- The functions taking a `chars_format` parameter determine the conversion
23
- specifier for `printf` as follows: The conversion specifier is `f` if
24
- `fmt` is `chars_format::fixed`, `e` if `fmt` is
25
- `chars_format::scientific`, `a` (without leading `"0x"` in the result)
26
- if `fmt` is `chars_format::hex`, and `g` if `fmt` is
27
- `chars_format::general`.
28
-
29
- ``` cpp
30
- to_chars_result to_chars(char* first, char* last, see below value, int base = 10);
31
- ```
32
-
33
- *Requires:* `base` has a value between 2 and 36 (inclusive).
34
-
35
- *Effects:* The value of `value` is converted to a string of digits in
36
- the given base (with no redundant leading zeroes). Digits in the range
37
- 10..35 (inclusive) are represented as lowercase characters `a`..`z`. If
38
- `value` is less than zero, the representation starts with a minus sign.
39
-
40
- *Throws:* Nothing.
41
-
42
- *Remarks:* The implementation shall provide overloads for all signed and
43
- unsigned integer types and `char` as the type of the parameter `value`.
44
-
45
- ``` cpp
46
- to_chars_result to_chars(char* first, char* last, float value);
47
- to_chars_result to_chars(char* first, char* last, double value);
48
- to_chars_result to_chars(char* first, char* last, long double value);
49
- ```
50
-
51
- *Effects:* `value` is converted to a string in the style of `printf` in
52
- the `"C"` locale. The conversion specifier is `f` or `e`, chosen
53
- according to the requirement for a shortest representation (see above);
54
- a tie is resolved in favor of `f`.
55
-
56
- *Throws:* Nothing.
57
-
58
- ``` cpp
59
- to_chars_result to_chars(char* first, char* last, float value, chars_format fmt);
60
- to_chars_result to_chars(char* first, char* last, double value, chars_format fmt);
61
- to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt);
62
- ```
63
-
64
- *Requires:* `fmt` has the value of one of the enumerators of
65
- `chars_format`.
66
-
67
- *Effects:* `value` is converted to a string in the style of `printf` in
68
- the `"C"` locale.
69
-
70
- *Throws:* Nothing.
71
-
72
- ``` cpp
73
- to_chars_result to_chars(char* first, char* last, float value,
74
- chars_format fmt, int precision);
75
- to_chars_result to_chars(char* first, char* last, double value,
76
- chars_format fmt, int precision);
77
- to_chars_result to_chars(char* first, char* last, long double value,
78
- chars_format fmt, int precision);
79
- ```
80
-
81
- *Requires:* `fmt` has the value of one of the enumerators of
82
- `chars_format`.
83
-
84
- *Effects:* `value` is converted to a string in the style of `printf` in
85
- the `"C"` locale with the given precision.
86
-
87
- *Throws:* Nothing.
88
-
89
- ISO C 7.21.6.1.
90
-