Fix: Resolve IntelliSense/linter false positive for type_is_unformattable_for

- Make type_is_unformattable_for a complete struct definition
- Replace variable declaration with static_assert for compile-time errors
- Fixes false positive IDE errors while maintaining original behavior

Fixes issue where IDEs like VS Code show red error indicators in file tree
for projects using fmt, even though compilation succeeds.
This commit is contained in:
Subash Chandra 2025-12-21 07:25:41 -06:00
parent 91d1aced0a
commit 0438dd20f8

View File

@ -2148,7 +2148,9 @@ auto get_iterator(buffer<T>&, OutputIt out) -> OutputIt {
}
// This type is intentionally undefined, only used for errors.
template <typename T, typename Char> struct type_is_unformattable_for;
template <typename T, typename Char> struct type_is_unformattable_for {
// Intentionally incomplete - causes compile error when instantiated
};
template <typename Char> struct string_value {
const Char* data;
@ -2311,7 +2313,8 @@ template <typename Context> class value {
FMT_CONSTEXPR value(const T&, custom_tag) {
// Cannot format an argument; to make type T formattable provide a
// formatter<T> specialization: https://fmt.dev/latest/api#udt.
type_is_unformattable_for<T, char_type> _;
static_assert(sizeof(T) != sizeof(T),
"Type is not formattable. Provide a formatter<T> specialization.");
}
// Formats an argument of a custom type, such as a user-defined class.