diff --git a/sprout/integer/integer_digits.hpp b/sprout/integer/integer_digits.hpp new file mode 100644 index 00000000..e23b8349 --- /dev/null +++ b/sprout/integer/integer_digits.hpp @@ -0,0 +1,92 @@ +#ifndef SPROUT_INTEGER_INTEGER_DIGITS_HPP +#define SPROUT_INTEGER_INTEGER_DIGITS_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace detail { + // + // integer_digits_impl + // + template + struct integer_digits_impl + : public std::integral_constant< + std::size_t, + (CHAR_BIT * sizeof(IntType) - (std::is_signed::value ? 1 : 0)) * N / D + + ((CHAR_BIT * sizeof(IntType) - (std::is_signed::value ? 1 : 0)) * N % D ? 1 : 0) + > + {}; + } // namespace detail + + // + // integer_digits + // + template + struct integer_digits; + + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; + template + struct integer_digits + : public sprout::detail::integer_digits_impl + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_INTEGER_INTEGER_DIGITS_HPP