|
SofaBuffers C/C++ 0.12.0
API Documentation
|
A CORELIB_PLAN §6.2.1 receiver cap, exactly as the caller states it. More...
#include <sofab.hpp>
Public Member Functions | |
| constexpr | DynCap () noexcept=default |
| The unstated cap: missing, not unlimited. | |
| constexpr | DynCap (std::size_t v) noexcept |
State the cap. v is a maximum: n > v is refused. | |
| template<typename T > requires std::is_signed_v<T> | |
| constexpr | DynCap (T)=delete |
Deleted: a signed cap would let -1 re-enter as an unlimited mode. | |
| constexpr bool | stated () const noexcept |
| Whether the caller stated a number at all. | |
| constexpr std::size_t | value () const noexcept |
| The stated maximum. Meaningless unless stated. | |
A CORELIB_PLAN §6.2.1 receiver cap, exactly as the caller states it.
§6.2.1 draws a line this type exists to make unforgeable: the provenance of a receiver limit is generated code's, and "there is no unset state and no unlimited mode". A codec "**MUST NOT** hold a limit of its own, <strong>MUST NOT</strong> supply a default for one it was not given, <strong>MUST NOT</strong> read an omitted argument as <em>unlimited</em>".
A long dynCap = -1 parameter breaks the last of those by construction: the sentinel is an omitted argument, and reading it as "no ceiling" is the unlimited mode the clause forbids. This type has no such spelling.
DynCap{64};DynCap is unstated, which is not "unlimited" but missing. Reaching it on a schema-unbounded field is an error in the call — the caller stated neither a schema bound nor a cap — and is reported as Error::InvalidArgument (§6.3), never decoded uncapped;-1 cannot be smuggled in as SIZE_MAX, which would be the unlimited mode wearing a new type.The number is still never held past the comparison it was passed for: a DynCap lives in the caller's collector or on the caller's stack, and this header only reads it.
|
constexprdefaultnoexcept |
The unstated cap: missing, not unlimited.
|
inlineexplicitconstexprnoexcept |
Deleted: a signed cap would let -1 re-enter as an unlimited mode.
|
inlineconstexprnoexcept |