Is there a way to include STL without having things defined in the global scope like ::size_t
? Implementation items like _security_init_cookie
are fine with me, as their identifiers are reserved.
vcruntime.h
is always included and this bothers me.
我认为这样做一点也不安全。
在全球空间中拥有事物需要向后兼容。如果您更改这些全局事物的签名,则会出现链接时间问题。正确的方法是将全局空间留给语言和库实现,并将您的东西放入命名空间中。
如果您分叉 STL,则必须维护每个版本并与其同步。
并且vcruntime.h
不是来自STL,而是与Windows相关的东西。
std::size_t
但是您可以使用:
#include <cstddef>
std::size_t i = 0;
Run Code Online (Sandbox Code Playgroud)
但::size_t
无论如何都会在那里。