Skip to content

[libc++][format] Should operator<<(thread::id) care about fmtflags in C++23? #62073

Closed
@JMazurkiewicz

Description

@JMazurkiewicz

Repro:

#include <cassert>
#include <format>
#include <sstream>
#include <thread>

using namespace std;

int main() {
  auto id = this_thread::get_id();
  const auto s1 = format("{}", id);
  ostringstream stream;
  stream << id;
  const auto s2 = stream.str(); // This is "text representation".
  assert(s2 == s1);             // Ok.

  stream.str("");
  stream << hex << id;
  const auto s3 =
      stream.str(); // Should this be the same "text representation"?
  assert(s3 == s1); // Currently, it is not.
}

Build:

PS D:\libcxx-playground> clang -std=c++2b -fexperimental-library -Iinclude\c++\v1 -llib\c++ "-llib\windows\clang_rt.builtins-x86_64" .\test.cpp
PS D:\libcxx-playground> .\a.exe
Assertion failed: s3 == s1, file .\test.cpp, line 20

The question is: should operator<<(thread::id) even care about fmtflags? It seems to me that since P2693R1 (partially implemented in 88622aa) the text representation is not longer "unspecified" and should always be the same, no matter what the fmtflags/locale/precision are.

CC: @mordante

Metadata

Metadata

Assignees

Labels

libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions