string: add string_view overload to to_upper
This commit is contained in:
parent
7b5a0b7ad0
commit
757253ee4e
@ -40,7 +40,7 @@ namespace cruft {
|
|||||||
/// Apply a functor to each character of a string and return the result.
|
/// Apply a functor to each character of a string and return the result.
|
||||||
template <typename FunctionT>
|
template <typename FunctionT>
|
||||||
std::string
|
std::string
|
||||||
transform (std::string const &val, FunctionT &&func)
|
transform (std::string_view val, FunctionT &&func)
|
||||||
{
|
{
|
||||||
std::string res;
|
std::string res;
|
||||||
res.reserve (val.size ());
|
res.reserve (val.size ());
|
||||||
@ -56,6 +56,13 @@ namespace cruft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string
|
||||||
|
to_upper (std::string_view const &val)
|
||||||
|
{
|
||||||
|
return transform (val, ::toupper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Convert the provided string to all upper case
|
/// Convert the provided string to all upper case
|
||||||
inline std::string
|
inline std::string
|
||||||
to_upper (std::string &&val)
|
to_upper (std::string &&val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user