Movatterモバイル変換


[0]ホーム

URL:



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

3266.to_chars(bool) should be deleted

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

Priority:0

View all otherissues in [charconv.syn].

View all issues withC++20 status.

Discussion:

28.2.2[charconv.to.chars] does not present an overload forbool(because it is neither a signed nor unsigned integer type), so an attempt to callto_chars with a bool argument would promote it toint and unambiguously call theint overload ofto_chars.

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

The user should cast explicitly if he wants the0/1 behavior. (Correspondingly, there is nobool overload forfrom_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 toN4830.

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

    […]// 28.2.2[charconv.to.chars], primitive numerical output conversionstruct 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);[…]

[8]ページ先頭

©2009-2026 Movatter.jp