template <typename T, typename CharT = char, typename Enable = void>
scanner struct
Scanner type, can be customized to enable scanning of user-defined types
Constructors, destructors, conversion operators
- scanner() deleted
- Default fallback implementation, not constructible, always an error.
Public functions
Function documentation
template <typename T, typename CharT, typename Enable>
template <typename ParseContext>
auto scn::scanner::parse(ParseContext& pctx) → typename ParseContext::iterator deleted constexpr
template <typename ParseContext>
Returns | On success, an iterator pointing to the } character at the end of the replacement field in the format string. Will cause an error, if the returned iterator doesn't point to a } character. |
---|
Parse the format string contained in pctx
, and populate *this
with the parsed format specifier values, to be used later in scan()
.
Should be constexpr
to allow for compile-time format string checking.
A common pattern is to inherit a scanner
implementation from another scanner
, while only overriding scan()
, and keeping the same parse()
, or at least delegating to it.
To report errors, an exception derived from std::
can be thrown, or ParseContext::on_error
can be called.
template <typename T, typename CharT, typename Enable>
template <typename Context>
auto scn::scanner::scan(T& value,
Context& ctx) const → expected< typename Context::iterator, scan_error > deleted
template <typename Context>
Returns | On success, an iterator pointing past the last character consumed from ctx . |
---|
Scan a value of type T
from ctx
into value
, using the format specs in *this
, populated by parse()
.
value
is guaranteed to only be default initialized.