Skip to content

Latest commit

 

History

History
51 lines (30 loc) · 1.08 KB

Kwargs_DataItem.md

File metadata and controls

51 lines (30 loc) · 1.08 KB

struct DataItem

Description

KwargsValue 的包装器,类似于 std::optional

Public member functions

operator->()

constexpr const DataItem* operator->() const noexcept

return this

hasValue()

constexpr bool hasValue() const noexcept

如果不为空(包含值)则返回 true,否则返回 false

valueOr()

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")