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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 18 13:48:30 PDT 2025


https://github.com/ldionne requested changes to this pull request.

> @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.

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 https://github.com/llvm/llvm-project/pull/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.

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


More information about the libcxx-commits mailing list