[libcxx-commits] [libcxx] [libc++] Make the body of println(FILE*) dependent on the template parameter to avoid template instantiation (PR #200996)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 15 00:12:31 PDT 2026


philnik777 wrote:

> > I'm not convinced this is a good idea as-is. The `template <class = void>` is meant to be there temporarily, and this patch makes it basically a permanent requirement.
> 
> The template head is there temporarily for what end? What would it ultimately be replaced with?

See the comment on it.

> I also don't see how this makes it permanently required. If the template parameter is removed, then the body of the function can be changed back. There is no effect on ABI or API boundaries here, so it can be freely changed whenever needed.

I didn't mean permanent in the sense that we can't change it, but permanent in the sense that there is no more plan to remove it.

> Again though, I'm happy with any solution that avoids instantiating all those templates I mentioned in the original issue. This can be reverted in favour of something better. I just don't want all those function template instantiations.

I'm actually somewhat partial to using `std::putc` directly instead, since that would also reduce the amount of code the optimizer has to churn through. Thinking about it, that would actually solve multiple issues (for this specific overload) at once. We don't need to care about availability anymore, so the template could be removed, we could probably get rid of the `_LIBCPP_ALWAYS_INLINE`, since the body should be quite small at that point, and we'd avoid instantiating anything in other `std::print` overloads.

I guess I'd have to see how it looks and decide based on that whether it's the better option.

https://github.com/llvm/llvm-project/pull/200996


More information about the libcxx-commits mailing list