Import std module
From: https://learn.microsoft.com/en-us/cpp/cpp/tutorial-import-stl-named-module?view=msvc-170#standard-library-named-module-considerations
Don’t mix and match importing header units and named modules. For example, don’t import <vector>;
and import std;
in the same file.
Don’t mix and match importing C++ standard library header files and the named modules std
or std.compat
. For example, don’t #include <vector>
and import std;
in the same file. However, you can include C headers and import named modules in the same file. For example, you can import std;
and #include <math.h>
in the same file. Just don’t include the C++ standard library version <cmath>
.
You don’t have to defend against importing a module multiple times. That is, you don’t need #ifndef
style header guards in modules. The compiler knows when it has already imported a named module and ignores duplicate attempts to do so.
If you need to use the assert()
macro, then #include <assert.h>
.
If you need to use the errno
macro, #include <errno.h>
. Because named modules don’t expose macros, this is the workaround if you need to check for errors from <math.h>
, for example.
Macros such as NAN
, INFINITY
, and INT_MIN
are defined by <limits.h>
, which you can include. However, if you import std;
you can use numeric_limits<double>::quiet_NaN()
and numeric_limits<double>::infinity()
instead of NAN
and INFINITY
, and std::numeric_limits<int>::min()
instead of INT_MIN
.