From 6b2c2f9c8246aa5a4559d30314c243eb59127e5e Mon Sep 17 00:00:00 2001 From: tlk00 Date: Sun, 13 Feb 2022 10:28:12 -0500 Subject: [PATCH] Allow bvector<>::clear() for read-only frozen vectors --- src/bm.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/bm.h b/src/bm.h index 5236b2c6..fe645991 100644 --- a/src/bm.h +++ b/src/bm.h @@ -1270,13 +1270,13 @@ class bvector \param free_mem if "true" (default) bvector frees the memory, otherwise sets blocks to 0. */ - void clear(bool free_mem = true) { blockman_.set_all_zero(free_mem); } + void clear(bool free_mem = true) BMNOEXCEPT; /*! \brief Clears every bit in the bitvector. \return *this; */ - bvector& reset() { clear(true); return *this; } + bvector& reset() BMNOEXCEPT { clear(true); return *this; } /*! \brief Flips bit n @@ -4121,6 +4121,20 @@ void bvector::keep(const size_type* ids, size_type ids_size, // ----------------------------------------------------------------------- +template +void bvector::clear(bool free_mem) BMNOEXCEPT +{ + if (is_ro()) + { + BM_ASSERT(free_mem); + blockman_.destroy_arena(); + } + else + blockman_.set_all_zero(free_mem); +} + +// ----------------------------------------------------------------------- + template void bvector::clear(const size_type* ids, size_type ids_size, bm::sort_order so)