Header Units
Learn how to use header units in C++20.
We'll cover the following...
By the end of 2020, no compiler, so far, supported header units. Header units are a smooth way to transition from headers to modules. You just have to replace the #include
directive with the new import
directive.
Press + to interact
#include <vector> => import <vector>;#include "myHeader.h" => import "myHeader.h";
Why header units?
First, import respects the same lookup rules as include
. This means in the case of the quotes ("myHeader.h"
) that the lookup first searches in the local directory before it continues with the system search path. ...