@@ -202,30 +202,21 @@ template <unsigned Bits, bool Signed> class Integral final {
202202
203203 static Integral min (unsigned NumBits) { return Integral (Min); }
204204 static Integral max (unsigned NumBits) { return Integral (Max); }
205+ static Integral zero (unsigned BitWidth = 0 ) { return from (0 ); }
205206
206- template <typename ValT> static Integral from (ValT Value) {
207- if constexpr (std::is_integral<ValT>::value)
207+ template <typename ValT>
208+ static Integral from (ValT Value, unsigned NumBits = 0 ) {
209+ if constexpr (std::is_integral_v<ValT>)
208210 return Integral (Value);
209211 else
210- return Integral::from (static_cast <Integral::ReprT>(Value));
212+ return Integral (static_cast <Integral::ReprT>(Value));
211213 }
212214
213215 template <unsigned SrcBits, bool SrcSign>
214- static std::enable_if_t <SrcBits != 0 , Integral>
215- from (Integral<SrcBits, SrcSign> Value) {
216+ static Integral from (Integral<SrcBits, SrcSign> Value) {
216217 return Integral (Value.V );
217218 }
218219
219- static Integral zero (unsigned BitWidth = 0 ) { return from (0 ); }
220-
221- template <typename T> static Integral from (T Value, unsigned NumBits) {
222- return Integral (Value);
223- }
224-
225- static bool inRange (int64_t Value, unsigned NumBits) {
226- return CheckRange<ReprT, Min, Max>(Value);
227- }
228-
229220 static bool increment (Integral A, Integral *R) {
230221 return add (A, Integral (ReprT (1 )), A.bitWidth (), R);
231222 }
@@ -328,13 +319,6 @@ template <unsigned Bits, bool Signed> class Integral final {
328319 return false ;
329320 }
330321 }
331- template <typename T, T Min, T Max> static bool CheckRange (int64_t V) {
332- if constexpr (std::is_signed_v<T>) {
333- return Min <= V && V <= Max;
334- } else {
335- return V >= 0 && static_cast <uint64_t >(V) <= Max;
336- }
337- }
338322};
339323
340324template <unsigned Bits, bool Signed>
0 commit comments