[libcxx-commits] [libcxx] [libc++] Avoid including vector in <functional> (PR #144310)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 18 13:59:45 PDT 2025


philnik777 wrote:

> > @ldionne Just so you know, this will affect C++23. This is an example why I think #134143 wouldn't actually help much. I think this will be way more common than removing public headers.
> 
> Ah, you are right, I missed that the block was guarded like this:
> 
> ```
> #  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
> ```
> 
> `<= 20` means that this doesn't apply to C++23.
> 
> In that case, I do have an issue with this patch as-is. It would be trivial for us to keep including `<vector>` from `<functional>` in C++23 (which is a stable standard mode) to avoid breaking people.

What do you mean by "stable standard mode"?

> We can then be intentional about dropping these transitive includes when we so desire, with a plan. I'm in favour of dropping transitive includes and forcing people to include what they use. I have little sympathy for keeping tech debt around just for the sake of not roughing feathers. However, I also think that we need to be intentional about what we break and when, otherwise we're expanding important "user sympathy" capital by breaking people often and for a questionable benefit.
> 
> I'd much rather ship #134143 (perhaps with a rewording that explains the intent better now that this goes beyond just checking transitive public includes), and then add `#include <vector>` to this patch in C++23 mode.

I don't think that's a viable path forward. You're basically asking to double the include time of `<functional>` to make things work with our current tests to avoid removing includes. IMO that's not something we should ever do.


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


More information about the libcxx-commits mailing list