Skip to content

Commit

Permalink
Rename integer_t -> extended_integer
Browse files Browse the repository at this point in the history
  • Loading branch information
StarQTius committed Aug 20, 2024
1 parent 8cefc3b commit 7595962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/upd/basic_ibytestream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class basic_ibytestream {
using byte_t = std::remove_reference_t<decltype(*std::declval<Producer_T>())>;

constexpr static auto byte_width = [] {
if constexpr (detail::is_instance_of_v<byte_t, integer_t>) {
if constexpr (detail::is_instance_of_v<byte_t, extended_integer>) {
return byte_t::width;
} else if constexpr (std::is_integral_v<byte_t>) {
return std::numeric_limits<byte_t>::digits;
} else if constexpr (std::is_enum_v<byte_t>) {
return std::numeric_limits<std::underlying_type_t<byte_t>>::digits;
} else {
static_assert(UPD_ALWAYS_FALSE, "Producers can only produce `integer_t` values, integral values or enumerators");
static_assert(UPD_ALWAYS_FALSE, "Producers can only produce `extended_integer` values, integral values or enumerators");
}
}();

Expand Down
11 changes: 7 additions & 4 deletions include/upd/integer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ constexpr auto has_value_member_v = has_value_member<T>::value;
namespace upd {

template<typename Bitsize, typename Underlying_T>
class integer_t {
class extended_integer {
static_assert(detail::has_value_member_v<Bitsize>, "`Bitsize` must has a `value` member");
static_assert(std::is_same_v<decltype(Bitsize::value), std::size_t>,
"`Bitsize::value` must be of type `std::size_t`");
Expand All @@ -34,7 +34,7 @@ class integer_t {
constexpr static auto is_signed = std::is_signed_v<Underlying_T>;

template<typename T, T Value>
constexpr integer_t(std::integral_constant<T, Value>) noexcept : m_value{Value} {
constexpr extended_integer(std::integral_constant<T, Value>) noexcept : m_value{Value} {
if constexpr (Value > 0) {
static_assert(Value >> bitsize == 0, "`Value` cannot be represented with `Bitsize` bits");
} else {
Expand All @@ -55,9 +55,12 @@ class integer_t {
};

template<std::size_t Bitsize>
using int_t = integer_t<detail::integral_constant_t<Bitsize>, std::intmax_t>;
using xint = extended_integer<detail::integral_constant_t<Bitsize>, std::intmax_t>;

template<std::size_t Bitsize>
using uint_t = integer_t<detail::integral_constant_t<Bitsize>, std::uintmax_t>;
using xuint = extended_integer<detail::integral_constant_t<Bitsize>, std::uintmax_t>;

template<std::size_t Bitsize, typename Underlying>
using xinteger = extended_integer<detail::integral_constant_t<Bitsize>, Underlying>;

} // namespace upd

0 comments on commit 7595962

Please sign in to comment.