开发者

Is it safe to define _HAS_TRADITIONAL_STL to enable STL functionality?

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 gua开发者_开发知识库rd.

  • Is there a reason for this?

  • Is it safe to simply define _HAS_TRADITIONAL_STL before including <functional>?


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 own select1st function:

template <typename PairT>
struct select1st : public std::unary_function<PairT, typename PairT::first_type>
{
    typename PairT::first_type operator()(const PairT& a) { return a.first; }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜