C2672 "std::_Variant_raw_get": не найдена соответствующая перегруженная функция
typedef std::variant<bool, LED::colour, LED::RateType, nullptr_t> ParamContainer;
std::get<std::string>(this->get_param());
Ошибка C2672 "std::_Variant_raw_get": не найдена соответствующая перегруженная функция
Самое странное, что этот же код компилируется нормально на Coliru. Кто-нибудь знает, почему я не смог собрать решение в Visual Studio в виду этой ошибки?
class Command // to execute it by manually calling LED functions (e.g. turning it off)
{
public:
typedef std::variant<bool, LED::colour, LED::RateType, nullptr_t> ParamContainer;
Command(const ParamContainer& c = nullptr) : // no arg by default
has_res(false),
param(c)
{
}
const ParamContainer& get_param() const
{
return this->param;
}
bool has_result() const
{
return this->has_res;
}
virtual bool apply(LED& l) = 0;
virtual void get_result(LED& l, std::string& d) = 0;
protected:
void set_flag(bool f)
{
this->has_res = f;
}
private:
bool has_res;
ParamContainer param;
};
class GetState : public Command
{
public:
GetState()
{
set_flag(true);
}
bool apply(LED&) override
{
// pass
return true;
}
void get_result(LED& l, std::string& d) override
{
if (has_result())
{
utils::to_string_state(l, d);
}
}
};
class SetState : public Command
{
public:
SetState(const ParamContainer& params) : Command(params)
{
}
bool apply(LED& led) override
{
try
{
std::get<std::string>(this->get_param());
std::string str;
if (str == "on")
{ }
bool v = true;
led.set_state(v);
}
catch (std::bad_variant_access&) // no arg
{
return false;
}
return true;
}
void get_result(LED& l, std::string& d) override
{
// pass
// this command has no output
}
};