范围设置 - “列表”类型返回什么?

范围设置 - “列表”类型返回什么?

我正在尝试使用以下代码从列表(在 settings.ini 中定义为名称为 [listname])中选择字符串:

unity::scopes::VariantMap config = settings();
std::string selected_string = config["listname"].get_string();

然而它是这样说的:

ScopeBase::run(): unity::LogicException: Variant does not contain a string value:
boost::bad_get: failed value get using boost::get

Variant 变量包含什么?如何检索选定的条目?

答案1

好的,我刚刚明白了,Variant 包含一个整数,因此应该使用:

config["listname"].get_int();

然后在代码中完成其余操作(根据 settings.ini 中的值顺序)

相关内容