Is C++11 available in Visual Studio 2017?

The Visual C++ 2017 compiler is C++11/C++14 compliant with a few specific exceptions:

  • Expression SFINAE is implemented, but not complete.
  • Full C99 preprocessor support is limited due to some bugs with variadic macros
  • Two phase name lookup is in VS 2017 (15.3 update) but is incomplete and only active when using /permissive-

The compiler does not offer a specific C++11 mode and defaults to C++14, but that standard is fully inclusive of C++11. C++17 support is in progress, and requires you use the /std:c++17 or /std::c++latest switch.

std::stoi requires you include the appropriate header, specifically <string>> Either you forgot to include that header -or- you didn't deal with the namespace resolution (either explicitly as std:: or via using namespace std;)

See C++17 Features And STL Fixes In VS 2017 15.3 for the latest status of C++11/C++14/C++17 standards conformance as of the VS 2017 (15.3 update)

UPDATED: Now that you have posted your code, I see that the problem has nothing to do with which standard is supported. Your problem is that you don't know the secrets of how Precompiled Headers work.

Change:

#include <string>
#include "stdafx.h"

to:

#include "stdafx.h"
#include <string>

-or- add #include <string> to the precompiled header stdafx.h directly.

See Creating Precompiled Header Files


Microsoft I think has declared that

Note that there is no plan to add a C++11 switch. link

So there's not an explicit switch