Tuple-like type becomes unformattable if `<fmt/ranges.h>` is included
- Dominant language
- C++
- Stars
- 25.8k
- Forks
- 3.1k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 28
Description
I have a library that provides a type that for convenience can be destructed like so:
```cpp
auto [key, value] = obj;
```
To make the type formattable without having a dependency on fmtlib itself I provide a `format_as` function in the same namespace
```cpp
std::string format_as(FooType const& value) {
// ...
}
```
This works fine, except if `` has been included somewhere, where the following error appears:
```cpp
/opt/compiler-explorer/libs/fmt/12.0.0/include/fmt/ranges.h:172:21: error: no matching function for call to 'fmt::v12::detail::is_tuple_formattable_::check(fmt::v12::detail::tuple_index_sequence)'
172 | decltype(check(tuple_index_sequence{}))::value;
```
I've tested on 12.2.0 and trunk and got the same issue on both versions.
Full code: https://godbolt.org/z/GPEWoe3Y5
Contributor guide
Research direction
Start with fmt/ranges.h and reproduce the failure using the full code in the linked Compiler Explorer example. Trace the tuple-formattability check and verify that a tuple-like type with a same-namespace format_as function remains formattable after fmt/ranges.h is included.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100