Skip to content

<format>: The definition of __fmt_pair_like is wrong #60995

Open
@hewillk

Description

@hewillk

template <class _Tp>
concept __fmt_pair_like = __is_specialization_v<_Tp, pair> ||
// Use a requires since tuple_size_v may fail to instantiate,
(__is_specialization_v<_Tp, tuple> && requires { tuple_size_v<_Tp> == 2; });

requires { tuple_size_v<_Tp> == 2; } should only require the expression to be valid and not actually evaluate it, right?

https://godbolt.org/z/c6aMq4xzd

#include <iostream>
#include <vector>
#include <format>

int main() {
  std::vector<std::tuple<>> v(3);
  std::cout << std::format("{:nm}", v); // (), (), ()
}

Metadata

Metadata

Assignees

Labels

confirmedVerified by a second partyformatC++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