我有这样的代码:
boost::optional<double> result = _ind1.Value() / _ind2.Value();
每个 argboost::optional<double>
也是:
boost::optional<double> Value() {
return value;
}
错误是:
Error 1 error C2676: binary '/' : 'boost::optional<T>' does not define this operator or a conversion to a type acceptable to the predefined operator
2 IntelliSense: no operator "/" matches these operands
operand types are: boost::optional<double> / boost::optional<double>
我知道似乎只是没有定义部门。我希望结果是boost::none
如果两个参数中的任何一个是none
- 否则我希望它是正常的双除法。我应该自己写这个吗?