forked from HowardHinnant/date
Add string_view overloads to parse functions
This commit is contained in:
@@ -8070,6 +8070,16 @@ public:
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
#if HAS_STRING_VIEW
|
||||
parse_manip(std::basic_string_view<CharT> format, Parsable& tp,
|
||||
std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(format)
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
#endif // HAS_STRING_VIEW
|
||||
};
|
||||
|
||||
template <class Parsable, class CharT, class Traits, class Alloc>
|
||||
@@ -8175,6 +8185,57 @@ parse(const CharT* format, Parsable& tp,
|
||||
return {format, tp, &abbrev, &offset};
|
||||
}
|
||||
|
||||
#if HAS_STRING_VIEW
|
||||
|
||||
// basic_string_view formats
|
||||
|
||||
template <class Parsable, class CharT>
|
||||
inline
|
||||
auto
|
||||
parse(std::basic_string_view<CharT> format, Parsable& tp)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT>&>(), format.data(), tp),
|
||||
parse_manip<Parsable, CharT>{format, tp})
|
||||
{
|
||||
return {format, tp};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits, class Alloc>
|
||||
inline
|
||||
auto
|
||||
parse(std::basic_string_view<CharT> format,
|
||||
Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.data(),
|
||||
tp, &abbrev),
|
||||
parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev})
|
||||
{
|
||||
return {format, tp, &abbrev};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT>
|
||||
inline
|
||||
auto
|
||||
parse(std::basic_string_view<CharT> format, Parsable& tp, std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT>&>(), format.data(),
|
||||
tp, std::declval<std::basic_string<CharT>*>(), &offset),
|
||||
parse_manip<Parsable, CharT>{format, tp, nullptr, &offset})
|
||||
{
|
||||
return {format, tp, nullptr, &offset};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits, class Alloc>
|
||||
inline
|
||||
auto
|
||||
parse(std::basic_string_view<CharT> format, Parsable& tp,
|
||||
std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.data(),
|
||||
tp, &abbrev, &offset),
|
||||
parse_manip<Parsable, CharT, Traits, Alloc>{format, tp, &abbrev, &offset})
|
||||
{
|
||||
return {format, tp, &abbrev, &offset};
|
||||
}
|
||||
|
||||
#endif // HAS_STRING_VIEW
|
||||
|
||||
// duration streaming
|
||||
|
||||
template <class CharT, class Traits, class Rep, class Period>
|
||||
|
Reference in New Issue
Block a user