You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
取值的同时判断类型
int n;
bool ret = j["boolean"].get_value(&n); // 若取值成功,ret 为 true
c++在新标准中已经对这种情况做出标准做法:使用std::optional.
修改成标准代码:
取值的同时判断类型
int n;
auto ret = j["boolean"].get_value(); // 若取值成功,ret 为 true//get_value()应该返回std::optional<int>if(ret.has_value()) n = ret.value();
else { /*do some thing*/}
如果没有什么特殊需求,都应该使用标准库中的方法.
The text was updated successfully, but these errors were encountered:
我注意到README个段代码:
c++在新标准中已经对这种情况做出标准做法:使用std::optional.
修改成标准代码:
如果没有什么特殊需求,都应该使用标准库中的方法.
The text was updated successfully, but these errors were encountered: