Non-negative integral quantity used by resource accounts. 更多...
#include <ResourceAccount.h>
Public 成员函数 | |
| constexpr | Amount () noexcept=default |
| Construct zero. | |
| constexpr | Amount (std::int64_t value) noexcept |
| Construct an amount from a validated native value. | |
| constexpr std::int64_t | value () const noexcept |
| Return the native quantity at an explicit adapter boundary. | |
| constexpr bool | isZero () const noexcept |
| Whether the quantity is zero. | |
| eve::Result< Amount > | checkedAdd (Amount other) const |
| Add two quantities with overflow checking. | |
静态 Public 成员函数 | |
| static eve::Result< Amount > | from (std::int64_t value) |
| Validate and construct an amount. | |
| static constexpr Amount | zero () noexcept |
| Return zero. | |
友元 | |
| constexpr bool | operator== (const Amount &, const Amount &) noexcept=default |
| constexpr auto | operator<=> (const Amount &, const Amount &) noexcept=default |
| Operator <=>. | |
详细描述
Non-negative integral quantity used by resource accounts.
The raw constructor is explicit so an adapter can construct a value after validating a native balance. External input should use from(), which rejects negative values.
在文件 ResourceAccount.h 第 75 行定义.
构造及析构函数说明
◆ Amount() [1/2]
|
constexprdefaultnoexcept |
Construct zero.
被这些函数引用 checkedAdd(), from() , 以及 zero().
◆ Amount() [2/2]
|
inlineexplicitconstexprnoexcept |
Construct an amount from a validated native value.
- 参数
-
value Non-negative quantity; callers handling untrusted input should use from() instead.
在文件 ResourceAccount.h 第 85 行定义.
成员函数说明
◆ checkedAdd()
| eve::Result< Amount > eve::resource::Amount::checkedAdd | ( | Amount | other | ) | const |
Add two quantities with overflow checking.
- 返回
- The sum, or a failed Result when int64_t would overflow.
在文件 ResourceAccount.cpp 第 57 行定义.
引用了 Amount(), eve::Result< T >::failure() , 以及 eve::Result< T >::success().
◆ from()
|
static |
Validate and construct an amount.
- 参数
-
value Native quantity, which must be non-negative.
- 返回
- A validated amount or a rejected Result.
在文件 ResourceAccount.cpp 第 51 行定义.
引用了 Amount(), eve::Result< T >::failure(), eve::Result< T >::success() , 以及 value().
◆ isZero()
|
inlineconstexprnoexcept |
Whether the quantity is zero.
在文件 ResourceAccount.h 第 101 行定义.
◆ value()
|
inlineconstexprnoexcept |
Return the native quantity at an explicit adapter boundary.
在文件 ResourceAccount.h 第 98 行定义.
被这些函数引用 eve::resource::ResourceCost::create() , 以及 from().
◆ zero()
|
inlinestaticconstexprnoexcept |
友元及相关函数文档
◆ operator<=>
◆ operator==
该类的文档由以下文件生成:
- src/engine/common/ResourceAccount.h
- src/engine/common/ResourceAccount.cpp