C – Definition_HAS_TRADITIONAL_STL to enable STL function security?

Trying to use std::select1st from in a VS2008 project, I found that it was set by the _HAS_TRADITIONAL_STL guard.

> Is there any reason for this?
>Is it safe to simply define _HAS_TRADITIONAL_STL before including ?

std::select1st does not exist by default because it is not part of the C standard library. It is One of the parts of the Standard Template Library (STL) that is not adopted by the C standard.

I can’t find any documentation for _HAS_TRADITIONAL_STL on MSDN, and it doesn’t seem to be included with Visual Studio 2010 Used in the released version of the standard library. It may be included in the library by Dinkumware when it is provided to Microsoft.

Having said that, it may be safe to define whether you want to use std::select1st. Please. Note that anything enabled with this flag is implementation-specific and non-portable (may even change between versions of Visual C). You might better implement your own select1st function:

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

Trying to use std::select1st from in a VS2008 project, I found It is set by the _HAS_TRADITIONAL_STL guard.

>Is there any reason for this?
>Is it safe to simply define _HAS_TRADITIONAL_STL before including ?

The reason std::select1st does not exist by default is that it is not part of the C standard library. It is not adopted by the C standard in the Standard Template Library (STL)

I can’t find any documentation for _HAS_TRADITIONAL_STL on MSDN, and it doesn’t seem to be used in the version of the standard library released with Visual Studio 2010. It may be caused by Dinkumware is included in the library when it is provided to Microsoft.

That being said, it may be safe to define whether you want to use std::select1st. Please note that anything enabled with this flag is specific It is easy to implement and not portable (may even change between Visual C versions). You may better implement your own select1st function:

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

Leave a Comment

Your email address will not be published.