Skip to content

[libc++][format] Formatting range with m range-type is incorrect #90196

@JMazurkiewicz

Description

@JMazurkiewicz

[format.range.formatter], Table 80:

(m option) Indicates that the opening bracket should be "{", the closing bracket should be "}", the separator should be ", ", and each range element should be formatted as if m were specified for its tuple-type.

Current implementation does not format range elements as if m tuple-type was specified, see for example https://godbolt.org/z/nzenfobqW:

#include <format>
#include <print>
#include <vector>
#include <utility>

int main() {
    std::vector<std::pair<int, int>> v = {{1, 2}, {3, 4}, {5, 6}};
    std::println("{:m}", v);
}

Expected:

{1: 2, 3: 4, 5: 6}

Got:

{(1, 2), (3, 4), (5, 6)}

Metadata

Metadata

Assignees

Labels

formatC++20 std::format or std::print, and anything related to themlibc++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