ascii: add try_upper transform

This commit is contained in:
Danny Robson 2019-05-02 11:03:00 +10:00
parent 050897389b
commit f9aa13ad81

View File

@ -117,6 +117,19 @@ namespace cruft::ascii {
}
///------------------------------------------------------------------------
/// Convert an ASCII character into a upper case character if it is lower
/// case, else return it unchanged.
///
/// If you know the character is always lower case then prefer to_upper.
constexpr inline
char
try_upper (char c) noexcept
{
return is_lower (c) ? to_upper (c) : c;
}
///------------------------------------------------------------------------
/// Converts an upper case ASCII character into a lower case character.
///