Is C ++ 11 available in Visual Studio 2017?

I am currently using Visual Studio Community 2017. Studying the C ++ language standards in the project properties, they provide only C ++ 14 and C ++ 17. Since my code was executed for the previous assignment using the compiler for C ++ 11, I cannot run my code with functions like stoi. My question is, is there a way to add C ++ 11 to the locales for C ++?

I am creating a GUI DLL, my initializations are:

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

using namespace std;

Here I create a fraction class, the main errors follow in ifstream:

istream& operator>>(istream& in, Fraction& f) {

string number;
in >> number;                           //read the number

size_t delimiter = number.find("/");    //find the delimiter in the string "/"

if (delimiter != string::npos) {            //if delimiter is not empty

    int n = stoi(number.substr(0, delimiter));      //set numerator from string to integer before the "/"
    int d = stoi(number.substr(delimiter + 1));     //set denominator from string to integer after the "/"

    if (d == 0) { //if denominator is 0
        throw FractionException("Illegal denominator, cannot divide by zero.");  //illegal argument throw
    }
    else if (n == 0 && d != 0) {    //numerator is 0, then set values as zero fraction
        f.numVal = 0;
        f.denVal = 1;
    }
    else {                      //set the values into the fraction and normalize and reduce fraction to minimum
        f.numVal = n;
        f.denVal = d;

        f.normalizeAndReduce(f.numVal, f.denVal);
    }
}
else {  //else if there is no delimiter it would be a single integer
    f.numVal = stoi(number);
    f.denVal = 1;
}

return in;
}

I get the following errors:

C2679: binary '>>': no operator found which takes a right-hand operator of type 'std::string"
C3861: 'stoi' identifier not found

This method worked fine in eclipse, not sure what I am doing wrong.

+12
source share
4 answers

Visual ++ 2017 - ++ 11/++ 14, :

++ 11 ++ 14, ++ 11. ++ 17 /std: ++ 17 /std::c++latest.

std::stoi , <string>> - - namespace ( , std::, using namespace std;)

. ++ 17 STL VS 2017 15.3 ++ 11/++ 14/++ 17 VS 2017 ( 15.3)

: , , , , . , Precompiled Headers.

:

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

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

-or- #include <string> stdafx.h.

.

+25

, Microsoft ,

, ++ 11.

+1

, VS 2017, 9.4 ( 2018) ++ 17.

0

++ - - 2003 2011 (++ 11), 2014 (++ 14), 2017 (++ 17), 2020 (++ 20). .

Microsoft Visual ++ .

-6

Source: https://habr.com/ru/post/1688479/


All Articles