Rename the default translator and make a typedef for capital ASCII letters.

This commit is contained in:
King_DuckZ 2018-07-24 19:49:41 +01:00
parent e1f7f3291f
commit cbeb12afdd

View file

@ -140,7 +140,7 @@ namespace dhandy {
} //namespace implem } //namespace implem
template <typename C, C FirstLetter='a'> template <typename C, C FirstLetter='a'>
struct DefaultTranslator { struct ASCIITranslator {
static constexpr C to_digit (unsigned int num) { static constexpr C to_digit (unsigned int num) {
return (num <= 9 ? return (num <= 9 ?
static_cast<C>(num + '0') : static_cast<C>(num + '0') :
@ -149,8 +149,10 @@ namespace dhandy {
} }
static constexpr C minus() { return '-'; } static constexpr C minus() { return '-'; }
}; };
template <typename C>
using ASCIITranslatorUpcase = ASCIITranslator<C, 'A'>;
template <typename I, unsigned int Base=10, typename Tr=DefaultTranslator<char>> template <typename I, unsigned int Base=10, typename Tr=ASCIITranslator<char>>
constexpr inline auto int_to_ary (I in) { constexpr inline auto int_to_ary (I in) {
return implem::IntConversion<std::decay_t<I>, Base, Tr>::to_ary(in); return implem::IntConversion<std::decay_t<I>, Base, Tr>::to_ary(in);
} }