Title
How does std::format work with character arrays of unknown bound?
Status
new
Section
[format.formatter.spec]
Submitter
S. B. Tam

Created on 2022-05-31.00:00:00 last changed 29 months ago

Messages

Date: 2022-06-15.00:00:00

[ 2022-06-21; Reflector poll ]

Set priority to 3 after reflector poll.

Date: 2022-05-31.00:00:00

Consider

#include <format>
#include <iostream>

extern char str[];
auto result = std::format("{}", str);
char str[] = "hello";

int main()
{
  std::cout << result << std::endl;
}

Currently MSVC STL (as well as fmtlib when fmt::format is used instead of std::format) accepts the initializer of result, while libc++ produces an error (apparently because there's no formatter for char[]).

Should this be valid?

Daniel:

This issue is similar to LWG 3701, but not the same, because the latter wants template<size_t N> struct formatter<charT[N], charT>, while this one needs template<>struct formatter<charT[], charT> (that is, without the array bound).

History
Date User Action Args
2022-06-21 11:46:11adminsetmessages: + msg12513
2022-05-31 00:00:00admincreate