diff --git a/include/duckhandy/implem/int_conv.hpp b/include/duckhandy/implem/int_conv.hpp index 5d9584c..d7c8782 100644 --- a/include/duckhandy/implem/int_conv.hpp +++ b/include/duckhandy/implem/int_conv.hpp @@ -70,6 +70,9 @@ namespace dhandy { static const constexpr std::size_t max_len = max_digit_count, I>::type, Base> + is_signed; }; + template + using RevArray = ReversedSizedArray::max_len + 1>; + template ::is_signed> struct IsNegative { static constexpr bool check (I) { return false; } }; template @@ -99,14 +102,13 @@ namespace dhandy { template struct IntConversion { - static constexpr ReversedSizedArray().to_digit(1))>, implem::int_info::max_len + 1> to_ary (I in) { - using RetType = ReversedSizedArray().to_digit(1))>, implem::int_info::max_len + 1>; + static constexpr RevArray to_ary (I in) { using Num = implem::NumberAdaptation; const bool was_negative = implem::is_negative(in); - RetType arr; - arr.push_front('\0'); + RevArray arr; + arr.push_front(Tr::NullChar); do { arr.push_front(Tr::to_digit(static_cast(Num::abs(Num::cast(in)) % Base))); in = static_cast(Num::cast(in) / static_cast(Base)); @@ -119,11 +121,9 @@ namespace dhandy { template struct IntConversion { - static constexpr ReversedSizedArray().to_digit(1))>, 2> to_ary (bool in) { - using RetType = ReversedSizedArray().to_digit(1))>, 2>; - - RetType arr; - arr.push_front('\0'); + static constexpr ReversedSizedArray to_ary (bool in) { + ReversedSizedArray arr; + arr.push_front(Tr::NullChar); arr.push_front(in ? Tr::to_digit(1) : Tr::to_digit(0)); return arr; } @@ -131,8 +131,8 @@ namespace dhandy { template struct IntConversion::value and not std::is_same::value>::type> { - static constexpr ReversedSizedArray().to_digit(1))>, implem::int_info::max_len + 1> to_ary (I in) { - using RetType = ReversedSizedArray().to_digit(1))>, implem::int_info::max_len + 1>; + static constexpr RevArray to_ary (I in) { + using RetType = RevArray; using Num = implem::NumberAdaptation; const constexpr char lookup[200] = { @@ -147,7 +147,7 @@ namespace dhandy { const bool was_negative = implem::is_negative(in); RetType arr; - arr.push_front('\0'); + arr.push_front(Tr::NullChar); while (Num::abs(in) >= static_cast(100)) { const auto index = (Num::abs(in) % 100) * 2; arr.push_front(Tr::to_digit(static_cast(lookup[index + 1]))); @@ -266,13 +266,15 @@ namespace dhandy { } } //namespace implem - template + template struct ASCIITranslator { + typedef C char_type; static const constexpr bool BehavesLikeASCII = true; static const constexpr C FirstDigit = FDigit; static const constexpr C FirstLetter = FLetter; static const constexpr C Plus = CPlus; static const constexpr C Minus = CMinus; + static const constexpr C NullChar = CNull; static constexpr C to_digit (unsigned int num) { return (num <= 9 ? @@ -293,7 +295,7 @@ namespace dhandy { template > constexpr inline auto int_to_ary (I in) { - return implem::IntConversion, Base, Tr>::to_ary(in); + return implem::IntConversion, Base, Tr>::to_ary(in); } template >