I am using Visual Studio 2017 - 15.9.7 for C++ development, and it looks like I have the necessary modules installed.
But the code below gives the error - "namespace "std" has no member "variant""
std::variant
is supported in C++17 and looks like it was introduced to Visual Studio in 15.0
#include <iostream>
#include <variant>
int main()
{
std::variant<int, double, std::string> value;
}
It looks like someone asked the same thing before, but the question appears to have been deleted.
Visual Studio 2017 version 15.3/std:c++17 enables the set of C++17 features implemented by the compiler.
To set this compiler option in the Visual Studio development environment. Open the project's Property Pages dialog box. For more information, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > Language property page.
Just select the “Individual Components” tab at the top of the installer screen and scroll down to the “Compilers, build tools, and runtimes” section. The 14.11 toolset is included in the VS2017 version 15.5 update 4 installer.
Available under /std:c++17 and /std:c++latest (or /std:c++20 starting in Visual Studio 2019 version 16.11):
You can also go
Project
> Properties
> C/C++
> Language
and set C++ Language Standard
to ISO C++17 Standard (/std:c++17)
make sure to be on All Configurations
and All Platforms
Project → Properties → C/C++ → Command Line /std:c++latest
Then click Apply and OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With