https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126675
Bug ID: 126675
Summary: Document std::__format::__do_vformat_to or make the
explicit instantiation extern
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: marco.rubini08 at gmail dot com
Target Milestone: ---
C++20 <format> is hard to use in large projects because the formatting
machinery is emitted in every TU that uses the std::format API and it takes too
long to compile.
A workaround is to write an 'extern template' explicit instantiation
declaration for std::__format::__do_vformat_to, like so:
```
namespace std::__format
{
extern template //
_Sink_iter<char> __do_vformat_to<char, 1>(_Sink_iter<char>,
string_view,
format_context&);
} // namespace std::__format
```
This results in a x20 object size reduction and ~x4 compile time speedup for a
TU that simply invokes std::vformat.
Please document the internal function to support the code above, or make the
explicit instantiation in <format> 'extern'. Doing so doesn't seem to result in
linker errors, because the template is also explicitly instantiated in
"c++20/format-inst.cc".