-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extern template
in non-header mode
#1452
Comments
Thanks for the suggestion but you can get better compile times by using the core API: https://fmt.dev/dev/api.html#core-api |
Is there some downsides of using extern template? I can think only of inlining, but this probably should not be the problem with string formatting library and could be resolved by lto |
The main drawback is duplication but I guess it can be addressed by only having the following two instantiations extern: extern template FMT_API std::string internal::vformat<char>(
string_view, basic_format_args<format_context>);
extern template FMT_API format_context::iterator internal::vformat_to(
internal::buffer<char>&, string_view, basic_format_args<format_context>); A PR would be welcome. |
I think we could avoid duplication by splitting
FMT_EXTERN template FMT_API std::string internal::vformat<char>(
string_view, basic_format_args<format_context>);
...
If it is ok, I'll make PR. |
If that's just two declarations I mentioned earlier then duplicating is fine. I don't think the rest save much and I'd rather not introduce another header just for this. |
Added Before (-O2):
After (-O2):
Before (default):
After (default):
Thanks for the suggestion! |
Compilation speed could be reduced significantly with the addition of extern template declaration in non-header mode.
Compilation times for the following snippet (with cmake release build):
The text was updated successfully, but these errors were encountered: