@@ -57,10 +57,12 @@ template <uint16_t size> struct stackvec {
57
57
FASTFLOAT_DEBUG_ASSERT (index < length);
58
58
return data[index ];
59
59
}
60
+
60
61
FASTFLOAT_CONSTEXPR14 const limb &operator [](size_t index) const noexcept {
61
62
FASTFLOAT_DEBUG_ASSERT (index < length);
62
63
return data[index ];
63
64
}
65
+
64
66
// index from the end of the container
65
67
FASTFLOAT_CONSTEXPR14 const limb &rindex (size_t index) const noexcept {
66
68
FASTFLOAT_DEBUG_ASSERT (index < length);
@@ -72,14 +74,19 @@ template <uint16_t size> struct stackvec {
72
74
FASTFLOAT_CONSTEXPR14 void set_len (size_t len) noexcept {
73
75
length = uint16_t (len);
74
76
}
77
+
75
78
constexpr size_t len () const noexcept { return length; }
79
+
76
80
constexpr bool is_empty () const noexcept { return length == 0 ; }
81
+
77
82
constexpr size_t capacity () const noexcept { return size; }
83
+
78
84
// append item to vector, without bounds checking
79
85
FASTFLOAT_CONSTEXPR14 void push_unchecked (limb value) noexcept {
80
86
data[length] = value;
81
87
length++;
82
88
}
89
+
83
90
// append item to vector, returning if item was added
84
91
FASTFLOAT_CONSTEXPR14 bool try_push (limb value) noexcept {
85
92
if (len () < capacity ()) {
@@ -89,12 +96,14 @@ template <uint16_t size> struct stackvec {
89
96
return false ;
90
97
}
91
98
}
99
+
92
100
// add items to the vector, from a span, without bounds checking
93
101
FASTFLOAT_CONSTEXPR20 void extend_unchecked (limb_span s) noexcept {
94
102
limb *ptr = data + length;
95
103
std::copy_n (s.ptr , s.len (), ptr);
96
104
set_len (len () + s.len ());
97
105
}
106
+
98
107
// try to add items to the vector, returning if items were added
99
108
FASTFLOAT_CONSTEXPR20 bool try_extend (limb_span s) noexcept {
100
109
if (len () + s.len () <= capacity ()) {
@@ -104,6 +113,7 @@ template <uint16_t size> struct stackvec {
104
113
return false ;
105
114
}
106
115
}
116
+
107
117
// resize the vector, without bounds checking
108
118
// if the new size is longer than the vector, assign value to each
109
119
// appended item.
@@ -119,6 +129,7 @@ template <uint16_t size> struct stackvec {
119
129
set_len (new_len);
120
130
}
121
131
}
132
+
122
133
// try to resize the vector, returning if the vector was resized.
123
134
FASTFLOAT_CONSTEXPR20 bool try_resize (size_t new_len, limb value) noexcept {
124
135
if (new_len > capacity ()) {
@@ -128,6 +139,7 @@ template <uint16_t size> struct stackvec {
128
139
return true ;
129
140
}
130
141
}
142
+
131
143
// check if any limbs are non-zero after the given index.
132
144
// this needs to be done in reverse order, since the index
133
145
// is relative to the most significant limbs.
@@ -140,6 +152,7 @@ template <uint16_t size> struct stackvec {
140
152
}
141
153
return false ;
142
154
}
155
+
143
156
// normalize the big integer, so most-significant zero limbs are removed.
144
157
FASTFLOAT_CONSTEXPR14 void normalize () noexcept {
145
158
while (len () > 0 && rindex (0 ) == 0 ) {
@@ -423,6 +436,7 @@ struct bigint : pow5_tables<> {
423
436
stackvec<bigint_limbs> vec;
424
437
425
438
FASTFLOAT_CONSTEXPR20 bigint () : vec() {}
439
+
426
440
bigint (bigint const &) = delete ;
427
441
bigint &operator =(bigint const &) = delete ;
428
442
bigint (bigint &&) = delete ;
0 commit comments