KwargsValue
的包装器,类似于 std::optional
。
constexpr const DataItem* operator->() const noexcept
return this
。
constexpr bool hasValue() const noexcept
如果不为空(包含值)则返回 true
,否则返回 false
。
template<typename _ValueType, typename... _Args>
constexpr _ValueType valueOr(_Args&&... __args) const noexcept
-
_ValueType
值的类型,需要显式指定,如果和原始值的类型不一致时将尝试使用内置类型转换器进行转换。
-
_Args
参数列表的类型。
-
__args
当对应的键没有值时,将使用该参数列表来调用
_ValueType
的构造函数进行原地构造并返回。示例:
dataItem.valueOr<std::string>(5, 'c');
如果
$dataItem$ 为空(不包含值),则返回std::string(5, 'c')
,同等于std::string("ccccc")
。