With C++26 std::optional range support, including both <fmt/std.h> and <fmt/ranges.h> fails with ambiguous template instantiation.
Environment
- fmt 12.1.0 (also reproduces on current
master at the time of writing)
- GCC 16.1.0, libstdc++ (ships P3168R2)
-std=c++26
- Linux x86_64
Reproduction
#include <optional>
#include <string>
#include <fmt/format.h>
// commenting either works.
// ranges prints: ["hi"] []
// std prints: optional("hi") none
#include <fmt/ranges.h>
#include <fmt/std.h>
int main() {
std::optional<std::string> some{"hi"};
std::optional<std::string> none{};
fmt::print("{} {}\n", some, none);
}
With C++26
std::optionalrange support, including both<fmt/std.h>and<fmt/ranges.h>fails withambiguous template instantiation.Environment
masterat the time of writing)-std=c++26Reproduction