Currently many header files are included but never used, since we don't have a mechanism or tool to help identify them. Tools like https://github.com/include-what-you-use/include-what-you-use can do the trick.
Activity
[-]Remove unused headers includes[/-][+]Remove unused headers #includes[/+]aosewski commentedon Apr 1, 2022
There is great tool pre-commit which can be configured with plugins to do such thing, and it can even do formatting, static analysis etc.
Take a look at available hooks (filter with C++ type) https://pre-commit.com/hooks.html
Here's one repo with some C++ hooks: https://github.com/pocc/pre-commit-hooks