parse/value: add a string_view overload

This commit is contained in:
Danny Robson 2022-01-10 15:36:49 +10:00
parent 2488846e38
commit 94bc72d3a1

View File

@ -20,6 +20,13 @@ namespace cruft::parse {
/// The view is modified in place to reflect the unused data.
template <typename T> T value (cruft::view<const char *> &);
template <typename T> T value (cruft::view< char *> &);
template <typename T> T value (std::string_view &str)
{
cruft::view wrapper (str);
T res = value<T> (wrapper);
str = str.substr (str.size () - wrapper.size ());
return res;
}
/// Parses a prefix string to obtain an instance of T.