template <typename T, typename CharT = char, typename Enable = void>
scn::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

template <typename ParseContext>
auto parse(ParseContext& pctx) →  expected< typename ParseContext::iterator, scan_error > -> auto deleted constexpr
template <typename Context>
auto scan(T& value, Context& ctx) const →  expected< typename Context::iterator, scan_error > -> auto deleted

Function documentation

template <typename T, typename CharT, typename Enable>
template <typename ParseContext>
auto scn::scanner::parse(ParseContext& pctx) →  expected< typename ParseContext::iterator, scan_error > deleted constexpr

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.

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

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.