fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.84k stars 2.42k forks source link

Disable range formatter when user provides one #3961

Closed Arghnews closed 1 month ago

Arghnews commented 1 month ago

Disable formatting type as range if user provided format_as function exists, using that instead. Should fix issue raised in #3839 by @drouhard

Edit: ah, this will need a similar workaround to detail::is_formattable_delayed for old msvc versions, before it will pass all the CI tests

vitaut commented 1 month ago

Thanks for the PR but I don't think this will work for formatter specializations and having this just for format_as would be inconsistent. fmt::format and std::format already have an opt out mechanism for ranges.

jdrouhard commented 1 month ago

What is the opt-out mechanism for a type if I don't want to include <fmt/ranges.h> in the header where the type is defined?

vitaut commented 1 month ago

You could probably forward declare is_range but I would recommend including <fmt/ranges.h> since you are effectively defining formatting for ranges.