Vuillemot Florian Vuillemot Florian - 8 months ago 124
C++ Question

c++ variant No such file or directory

I have a problem compiling code using std::variant.
I try to compile this code with g++ 5.4/6.2 on ubuntu and fedora with -std=c++17:

#include <variant>
#include <string>

int main()
std::variant<int, float> v, w;
v = 12; // v contains int
int i = std::get<int>(v);
w = std::get<int>(v);
w = std::get<0>(v); // same effect as the previous line
w = v; // same effect as the previous line

try {
std::get<float>(w); // w contains int, not float: will throw
catch (std::bad_variant_access&) {}

std::variant<std::string> v("abc"); // converting constructors work when unambiguous
v = "def"; // converting assignment also works when unambiguous

found on but this error append: "fatal error: variant: No such file or directory".


std::variant was added in C++17.

gcc does not yet fully support the relevant bits of the C++17 standard.

I don't even see std::variant listed in the gcc's tracking page.