I am very new to C++ and programming in general and am currently working through Bjarne Stroustrup\'s Programming: Principles and Practices using C++. I\'m consistently rece
The warning isn't about "some function" - it's about the whole of stdext
. And it's not just hand-wavy, to be discontinued eventually, deprecated: it doesn't ship with 2015.
During the early 00's work was afoot to revise the C++ standard; different compiler vendors, Microsoft included, put proposals before the committee along with prototypes. So they could be tested and evaluated, Microsoft placed implementations of their proposed extensions in stdext
.
Eventually the committee chose what they were going to incorporate in that revision and released a Technical Report ("TR1"). Anticipating completion before the end of 2009, this was referred to as "C++0x", and compiler vendors began implementing these features in the tr1
namespace. Finally in 2011 the standard was finalized and we got "C++11" with all its bit and pieces back in std
where they belong.
According to Microsoft's proposal, the container would be std::hash_map
, but the C++ committee chose to use the term unordered_map
. std::map
is an ordered container, stdext::hash_map
, despite the name, is not.
Microsoft's compiler has been the slowest at getting full C++11 support finished, and the standards committee has since finished a second variation (C++14) and is working on a third (C++17). Microsoft is just-about finishing C++11 in VS2015 and a big chunk of C++14, with a few significant exceptions that are apparently going to be a major problem for the VS compiler (esp constexpr and template variables).
Visual Studio 2015 does not provide stdext
- it's gone. This is not one of those "well, it may eventually go away" cases.
stdext
is specific to the Microsoft family of compilers, so writing code using stdext::
anything is not portable: http://ideone.com/x8GsKY
The standardized version of the feature you're wanting is std::unordered_map, you should use that. It's essentially the same thing.
There are unresolved bugs in stdext::hash_map
.
If you really have to use stdext::hash_map
, silence the warning by adding
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
at the top of the stdafx.h
I assume your project has, or in your header files before you #include
, or in the solution explorer:
All Configurations
,C/C++
tree entry,Preprocessor
,
_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1;
so it reads _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1;
.
(or whatever was there originally should follow the ;
)