parse/value: add a string_view overload
This commit is contained in:
parent
2488846e38
commit
94bc72d3a1
@ -20,6 +20,13 @@ namespace cruft::parse {
|
|||||||
/// The view is modified in place to reflect the unused data.
|
/// 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<const char *> &);
|
||||||
template <typename T> T value (cruft::view< 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.
|
/// Parses a prefix string to obtain an instance of T.
|
||||||
|
Loading…
Reference in New Issue
Block a user