Write digitToChar() in a more compact way

testing/bash_completion_debugging
Martchus 5 years ago
parent 94136d9b85
commit 22c8e636dc
  1. 10
      conversion/stringconversion.h

@ -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);
}
/*!

Loading…
Cancel
Save