This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

### 3266. `to_chars(bool)` should be deleted

Section: 22.13.1 [charconv.syn] Status: C++20 Submitter: Jens Maurer Opened: 2019-08-23 Last modified: 2021-02-25

Priority: 0

View all other issues in [charconv.syn].

View all issues with C++20 status.

Discussion:

22.13.2 [charconv.to.chars] does not present an overload for `bool` (because it is neither a signed nor unsigned integer type), so an attempt to call `to_chars` with a bool argument would promote it to `int` and unambiguously call the `int` overload of `to_chars`.

This was not intended, since it is not obvious that the correct textual representation of a `bool` is `0/1` (as opposed to, say, `"true"/"false"`).

The user should cast explicitly if he wants the `0/1` behavior. (Correspondingly, there is no `bool` overload for `from_chars` in the status quo, and conversions do not apply there because of the reference parameter.)

[2019-09-14 Issue Prioritization]

Status to Tentatively Ready and priority to 0 after eight positive votes on the reflector.

Proposed resolution:

This wording is relative to N4830.

1. Modify 22.13.1 [charconv.syn], header `<charconv>` synopsis, as indicated:

   >     […]
   >     // 22.13.2 [charconv.to.chars], primitive numerical output conversion
   >     struct to_chars_result {
   >       char* ptr;
   >       errc ec;
   >       friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
   >     };

   >     to_chars_result to_chars(char* first, char* last, see below value, int base = 10);
   >     to_chars_result to_chars(char* first, char* last, bool value, int base = 10) = delete;
   >     to_chars_result to_chars(char* first, char* last, float value);
   >     […]