Import std module

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值