std :: variantを使用してコードをコンパイルする際に問題があります。 私はグラムで、このコードをコンパイルしようとする++ 5.4/6.2のUbuntuとFedoraに-std = C++ 17で:C++ variantこのようなファイルやディレクトリはありません
cppreference.comで見つけ#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
}
が、このエラーはappend:「致命的なエラー:バリアント:いいえ、そのようなファイルまたはディレクトリー "と呼びます。
は、すべてのフラグとの完全なコンパイラの呼び出しを記載してください。 'std :: variant'はC++ 17の機能です。 '-std = C++ 17'を指定しましたか? – Jonas
私はおかげで更新 –