Skip to content

Commit 7ed21ce

Browse files
authored
Fix long_int support
1. Add construction from bool type 2. Fix muldiv method is case if long_int type used
1 parent c5405a6 commit 7ed21ce

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

include/long_int.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class long_int_t : public long_uint_t<native_t, size>
6868
constexpr long_int_t(type_t value) noexcept;
6969
template<typename type_t, std::enable_if_t<std::is_signed_v<type_t>, int> = 0>
7070
constexpr long_int_t(type_t value) noexcept;
71+
constexpr long_int_t(bool value) noexcept;
7172

7273
////////////////////////////////////////////////////////////////////////////////////////////////
7374
// public methods
@@ -112,6 +113,17 @@ inline constexpr bool is_signed_v<long_int_t<native_t, size>> = true;
112113

113114

114115

116+
////////////////////////////////////////////////////////////////////////////////////////////////////
117+
// make_unsigned_t
118+
////////////////////////////////////////////////////////////////////////////////////////////////////
119+
120+
template<typename native_t, uint_t size>
121+
struct make_unsigned<long_int_t<native_t, size>> {
122+
using type = long_uint_t<native_t, size>;
123+
};
124+
125+
126+
115127
////////////////////////////////////////////////////////////////////////////////////////////////////
116128
// standalone methods
117129
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -159,6 +171,12 @@ constexpr long_int_t<native_t, size>::long_int_t(type_t value) noexcept
159171
{
160172
}
161173

174+
template<typename native_t, uint_t size>
175+
constexpr long_int_t<native_t, size>::long_int_t(bool value) noexcept
176+
: long_uint_t<native_t, size>(value)
177+
{
178+
}
179+
162180

163181

164182
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -484,7 +502,7 @@ constexpr long_int_t<native_t, size> operator/(type_t value1, const long_int_t<n
484502
template<typename type_t, std::enable_if_t<is_signed_v<type_t>, int>>
485503
constexpr type_t muldiv(const type_t& value, const type_t& multiplier, const type_t& divider) noexcept
486504
{
487-
using unsigned_t = std::make_unsigned_t<type_t>;
505+
using unsigned_t = make_unsigned_t<type_t>;
488506
const unsigned_t uvalue = value >= 0 ? value : -value;
489507
const unsigned_t umultiplier = multiplier >= 0 ? multiplier : -multiplier;
490508
const unsigned_t udivider = divider >= 0 ? divider : -divider;

0 commit comments

Comments
 (0)