Skip to content

Fix FMT_COMPILE failure with format_as mapped types (Issue #4794)#4836

Open
upadhyay74aman wants to merge 3 commits into
fmtlib:mainfrom
upadhyay74aman:fix-compile-format-as
Open

Fix FMT_COMPILE failure with format_as mapped types (Issue #4794)#4836
upadhyay74aman wants to merge 3 commits into
fmtlib:mainfrom
upadhyay74aman:fix-compile-format-as

Conversation

@upadhyay74aman

Copy link
Copy Markdown

This PR fixes an issue where FMT_COMPILE fails to compile when used with user-defined types formatted via format_as.

The Changes:

  • Introduced compile_has_format_as to check for format_as overloads at compile time via ADL.

  • Updated the format method inside detail::field in compile.h to branch using if constexpr, casting the argument via format_as if the type supports it.

  • Added a regression test to test/compile-test.cc to ensure compile-time format_as evaluation works as expected.

Closes #4794

@upadhyay74aman upadhyay74aman requested a review from vitaut as a code owner July 5, 2026 09:27
Comment thread include/fmt/compile.h Outdated
Comment thread include/fmt/compile.h Outdated
Comment thread include/fmt/compile.h Outdated
Comment thread test/compile-test.cc
@upadhyay74aman

This comment has been minimized.

@vitaut vitaut force-pushed the fix-compile-format-as branch from 15cfdd0 to 5701167 Compare July 8, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FMT_COMPILE with user-defined type formatted via format_as fails to compile

3 participants