MCPcopy Create free account
hub / github.com/SheafificationOfG/based-cpp / read_int

Function read_int

gil/std.io.hpp:51–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49namespace integral {
50
51template <typename Int> static constexpr auto read_int() noexcept {
52 using _impl_::tmp;
53 constexpr auto is_neg = tmp[0];
54 constexpr auto succ = tmp[1];
55 return block_(skip_whitespace(), is_neg = peek_() == '-', succ = false,
56 tmp = static_cast<Int>(0),
57 loop_(if_(peek_(*is_neg) != none_ && peek_(*is_neg) <= '9' &&
58 peek_(*is_neg) >= '0')(
59 tmp = tmp * 10 + cast_<Int>(peek_(*is_neg) - '0'),
60 advance_(), succ = true)
61 ->else_(break_)),
62 if_(succ)(if_(is_neg)(advance_(), tmp *= static_cast<Int>(-1)),
63 break_(*tmp)));
64}
65
66template <typename Int> static constexpr auto write_int(auto var) noexcept {
67 using _impl_::tmp;

Callers

nothing calls this directly

Calls 7

block_Function · 0.85
skip_whitespaceFunction · 0.85
peek_Function · 0.85
loop_Function · 0.85
if_Function · 0.85
advance_Function · 0.85
else_Method · 0.80

Tested by

no test coverage detected