ascii: add try_lower

This commit is contained in:
Danny Robson 2019-05-01 12:30:39 +10:00
parent 5fb87ea4c4
commit 35ae04510f

View File

@ -131,6 +131,19 @@ namespace cruft::ascii {
}
///------------------------------------------------------------------------
/// Convert an ASCII character into a lower case character if it is upper
/// case, else return it unchanged.
///
/// If you know the character is always upper case then prefer to_lower.
constexpr inline
char
try_lower (char c) noexcept
{
return is_upper (c) ? to_lower (c) : c;
}
///////////////////////////////////////////////////////////////////////////
/// Returns true if the supplied ASCII character is whitespace.
constexpr inline