mardi 26 février 2019

VS10 C++ Error C2833: 'operator string' is not a recognized operator or type

I am trying to have a custom operator operator ""_exp for Exponent class that I could call the operator like this:

std::cout << 10.5 ** 2._exp << '\n';

My rest of the code:

struct Exponent
{
    long double value;
};

Exponent operator ""_exp(long double exponent)
{
    return exponent;
}

I am using Visual Studio 10 compiler and I get a C2883 error:

Error C2833: 'operator string' is not a recognized operator or type

I have tried:

I've found a list of possible user-defined operators but I couldn't find operator "". https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/ds533389(v%3dvs.100)

Question: Can somebody tell my is it possible to have operator ""_exp" in Visual Studio 2010? Or maybe there is another way to achieve this?

Aucun commentaire:

Enregistrer un commentaire