Which is the recommended order in which the #include directives are supposed to be listed? I could not find any answer in the C++ Core Guidelines
For example, should they be ordered like this:
#include "OtherHeaderInCurrentLib.h"
#include <third_party_library/header.h>
#include <iostream>
Or should they be ordered like this:
#include <iostream>
#include <third_party_library/header.h>
#include "OtherHeaderInCurrentLib.h"
And is there any difference between the recommended ordering when they are listed inside a source files and when they are listed inside a header files?
#includewhat's actually needed.#include "pch.h"<string>, it should include<string>. If you don't, but put it last after a stack of includes in a cpp that has#include <string>, that mishap is hidden... until you use it somewhere else where the consuming cpp didn't include<string>before your header, and now you're wondering wtf.. this worked before, why not now? In short, I agree with eerorika.