【发布时间】:2018-01-30 13:33:26
【问题描述】:
我正在审查一些代码并有这样的东西:
boost::optional<bool> isSet = ...;
... some code goes here...
bool smthelse = isSet ? *isSet : false;
所以我的问题是,最后一行是否等同于:
bool smthelse = isSet;
【问题讨论】:
-
bool smthelse = isSet.get_value_or(false);可能更容易阅读。
标签: c++ boost boolean optional boost-optional