Write digitToChar() in a more compact way

This commit is contained in:
Martchus 2017-06-29 18:24:11 +02:00
parent 94136d9b85
commit 22c8e636dc
1 changed files with 2 additions and 8 deletions

View File

@ -232,15 +232,9 @@ template <typename StringType> void findAndReplace(StringType &str, const String
* - Uses capital letters.
* - Valid values for \a digit: 0 <= \a digit <= 35
*/
template <typename CharType> CharType digitToChar(CharType digit)
template <typename CharType> constexpr CharType digitToChar(CharType digit)
{
CharType res;
if (digit <= 9) {
res = digit + '0';
} else {
res = digit + 'A' - 10;
}
return res;
return digit <= 9 ? (digit + '0') : (digit + 'A' - 10);
}
/*!