#4944·fmt

Tuple-like type becomes unformattable if `<fmt/ranges.h>` is included

Author: matcoolCreated Sep 12, 2026Updated Sep 12, 2026

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 <fmt/ranges.h> 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_<lib::FooType, char, true>::check(fmt::v12::detail::tuple_index_sequence<lib::FooType>)'
  172 |       decltype(check(tuple_index_sequence<T>{}))::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