定义 _HAS_TRADITIONAL_STL 来启用 STL 功能是否安全?
在尝试在 VS2008 项目中使用
中的 std::select1st
时,我发现它被 _HAS_TRADITIONAL_STL
ifdef 了。警卫。
这有什么原因吗?
在包含
之前简单地定义_HAS_TRADITIONAL_STL
是否安全?
In attempting to use std::select1st
from <functional>
in a VS2008 project I found that it was ifdef'd out by a _HAS_TRADITIONAL_STL
guard.
Is there a reason for this?
Is it safe to simply define
_HAS_TRADITIONAL_STL
before including<functional>
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下
std::select1st
不存在的原因是它不是 C++ 标准库的一部分。它是标准模板库 (STL) 中未采用 C++ 标准的部分之一。我在 MSDN 上找不到
_HAS_TRADITIONAL_STL
的任何文档,并且它似乎没有在随 Visual Studio 2010 分发的标准库版本中使用。它可能包含在 Dinkumware 的库中当他们将其交付给微软时。话虽如此,定义是否要使用 std::select1st 可能是安全的。请注意,使用该标志启用的任何内容都是特定于实现的且不可移植的(甚至可能在 Visual C++ 版本之间发生变化)。您最好实现自己的
select1st
函数:The reason
std::select1st
is not present by default is that it is not part of the C++ standard library. It is one of the parts of the Standard Template Library (STL) that was not adopted into the C++ standard.I can't find any documentation on MSDN for
_HAS_TRADITIONAL_STL
, and it doesn't appear to be used in the version of the standard library distributed with Visual Studio 2010. It is probably included in the library by Dinkumware when they deliver it to Microsoft.That having been said, it is probably safe to define if you want to use
std::select1st
. Just note that using anything enabled by that flag is implementation-specific and nonportable (and may even change between versions of Visual C++). You would probably be better off implementing your ownselect1st
function: