Includes order in CPP project
This include order isn’t anything special—it’s just one way to do it. If you’re struggling to decide how to structure your includes, feel free to use this template.
I’m also saving it here as a reference for myself, so I can reuse it in my own pet projects.
// ----------------------------------------------------------------------------
// Class Header (only for .cpp files, include the corresponding header first)
#include <MyProject/inc/FakeSnapshotProcessor.h>
// ----------------------------------------------------------------------------
// Alphabetical Project Includes (specific to your module)
#include <MyProject/inc/FakeDataExporter.h>
#include <MyProject/inc/FakeSnapshotIO.h>
// ----------------------------------------------------------------------------
// Alphabetical Project Common Includes (shared/common modules)
#include <MyProject/common/Diagnostics/inc/FakeLogger.h>
#include <MyProject/common/Exceptions/inc/FakeWarningHandler.h>
#include <MyProject/common/Messaging/inc/FakeMessageDispatcher.h>
#include <MyProject/common/Parameters/inc/FakeConfigTokens.h>
#include <MyProject/common/Runtime/inc/FakeRuntimeOptions.h>
#include <MyProject/common/System/inc/FakeDirectoryUtils.h>
#include <MyProject/common/System/inc/FakePreconditions.h>
// ----------------------------------------------------------------------------
// Alphabetical 3rd-party Includes
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <QImage>
// ----------------------------------------------------------------------------
// Alphabetical System Includes
#include <filesystem>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>