Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eliaskosunen committed Sep 23, 2024
1 parent 3c4a9c2 commit 2ca92c7
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/scn/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3875,25 +3875,38 @@ class tm_reader {
scan_error m_error{};
};

template <typename CharT, typename T, typename Context>
auto chrono_scan_impl(std::basic_string_view<CharT> fmt_str, T& t, Context& ctx)
-> scan_expected<typename Context::iterator>
template <typename CharT,
typename T,
typename Context,
typename Iterator,
typename Sentinel>
auto chrono_scan_inner_impl(std::basic_string_view<CharT> fmt,
T& t,
Context& ctx,
ranges::subrange<Iterator, Sentinel> rng)
-> scan_expected<Iterator>
{
{
SCN_TRY(it,
detail::internal_skip_classic_whitespace(ctx.range(), false));
SCN_TRY(it, detail::internal_skip_classic_whitespace(rng, false));
ctx.advance_to(SCN_MOVE(it));
}
auto r = detail::tm_reader<T, typename Context::range_type, CharT>(
ctx.range(), t, ctx.locale());
detail::parse_chrono_format_specs(fmt_str.data(),
fmt_str.data() + fmt_str.size(), r);

auto r = detail::tm_reader<T, ranges::subrange<Iterator, Sentinel>, CharT>(
rng, t, ctx.locale());
detail::parse_chrono_format_specs(fmt.data(), fmt.data() + fmt.size(), r);
if (auto e = r.get_error(); SCN_UNLIKELY(!e)) {
return unexpected(e);
}
return r.get_iterator();
}

template <typename CharT, typename T, typename Context>
auto chrono_scan_impl(std::basic_string_view<CharT> fmt_str, T& t, Context& ctx)
-> scan_expected<typename Context::iterator>
{
return chrono_scan_inner_impl(fmt_str, t, ctx, ctx.range());
}

template auto chrono_scan_impl(std::string_view, std::tm&, scan_context&)
-> scan_expected<scan_context::iterator>;
template auto chrono_scan_impl(std::string_view, tm_with_tz&, scan_context&)
Expand Down

0 comments on commit 2ca92c7

Please sign in to comment.