Is there a way to warn C++ developers when they accidentally include internal implementation headers of std library?
It seems like include-what-you-use does what you want.
It has a mapping of what names are supposed to come from what header, and it seems to know which headers are internal.
For example, when including <bits/shared_ptr.h> https://godbolt.org/z/cvq7354K6:
#include <bits/shared_ptr.h>

std::shared_ptr<int> x;

It says to remove <bits/shared_ptr.h> and add <memory>.

How to let know developers automatically that this "bits/shared_ptr.h" is internal to standard library (gcc and clang).
#include <bits/shared_ptr.h>

// some code using std::shared_ptr


The best would be to also inform <memory> should be used instead.
This <bits/shared_ptr.h> is just an example - I mean - how to warn about any implementation header being included.
By "automatically" I mean - compiler warning or static analysis like clang-tidy.
I have tried "-Wall -Wextra -pedantic" and all clang-tidy checks, without llvm* checks - these llvm* warns for almost every header and it is just for llvm developers, not for us, regular developers.
Any advice?
I prefer existing solution, I know I can write script for that.

Ok, I found one check in clang-tidy that I can use.
It is portability-restrict-system-includes
Just need to specify in config that "bits" things are not allowed:
-config="CheckOptions: {portability-restrict-system-includes.Includes: '*,-bits/*,bitset'}"
See demo.
But, well, it is not perfect solution - one would need to maintain list of "not allowed" headers.
