@@ -208,11 +208,13 @@ namespace bowen
208208
209209 reference operator [](size_t pos)
210210 {
211+ #ifndef BITVECTOR_DISABLE_BOUNDS_CHECK
211212 if (pos >= m_size){
212213 std::stringstream ss;
213214 ss << " bitvector index out of range" << " pos: " << pos << " size: " << m_size << std::endl;
214215 throw std::out_of_range (ss.str ());
215216 }
217+ #endif
216218
217219 size_t word_index = pos >> WORD_SHIFT;
218220 BitType mask = static_cast <BitType>(1 ) << (pos & (WORD_BITS - 1 ));
@@ -221,21 +223,25 @@ namespace bowen
221223
222224 bool operator [](size_t pos) const
223225 {
226+ #ifndef BITVECTOR_DISABLE_BOUNDS_CHECK
224227 if (pos >= m_size){
225228 std::stringstream ss;
226229 ss << " bitvector index out of range" << " pos: " << pos << " size: " << m_size << std::endl;
227230 throw std::out_of_range (ss.str ());
228231 }
232+ #endif
229233 size_t word_index = pos >> WORD_SHIFT;
230234 BitType mask = static_cast <BitType>(1 ) << (pos & (WORD_BITS - 1 ));
231235 return (m_data[word_index] & mask) != 0 ;
232236 }
233237 inline void set_bit (size_t pos, bool value){
238+ #ifndef BITVECTOR_DISABLE_BOUNDS_CHECK
234239 if (pos >= m_size){
235240 std::stringstream ss;
236241 ss << " bitvector index out of range" << " pos: " << pos << " size: " << m_size << std::endl;
237242 throw std::out_of_range (ss.str ());
238243 }
244+ #endif
239245 BitType mask = 1UL << (pos % WORD_BITS);
240246 BitType * ptr = &m_data[pos / WORD_BITS];
241247 if (value)
@@ -316,12 +322,14 @@ namespace bowen
316322 }
317323 void incrementUntilZero (size_t & pos){
318324 // Ensure the position is within bounds
325+ #ifndef BITVECTOR_DISABLE_BOUNDS_CHECK
319326 if (pos >= m_size){
320327 std::stringstream ss;
321328 ss << " bitvector index out of range" << " pos: " << pos << " size: " << m_size << std::endl;
322329 throw std::out_of_range (ss.str ());
323330 return ;
324331 }
332+ #endif
325333 while (pos < m_size&& pos%WORD_BITS!=0 && (*this )[pos] != 0 ) // Check if bit at pos is 1
326334 {
327335 ++pos; // Increment pos to the next bit
0 commit comments