Skip to content

Commit

Permalink
fix(common): allow StaticArray to wrap a nullptr if its size is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSeemaier committed Oct 12, 2024
1 parent 68f4ba9 commit 170f98a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions kaminpar-common/datastructures/static_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ template <typename T> class StaticArray {
}

value_type *data() {
KASSERT(_data);
KASSERT(_data || _size == 0);
return _data;
}

const value_type *data() const {
KASSERT(_data);
KASSERT(_data || _size == 0);
return _data;
}

Expand All @@ -260,12 +260,12 @@ template <typename T> class StaticArray {
//

iterator begin() {
KASSERT(_data);
KASSERT(_data || _size == 0);
return iterator(_data);
}

const_iterator begin() const {
KASSERT(_data);
KASSERT(_data || _size == 0);
return const_iterator(_data);
}

Expand All @@ -274,12 +274,12 @@ template <typename T> class StaticArray {
}

iterator end() {
KASSERT(_data);
KASSERT(_data || _size == 0);
return iterator(_data + _size);
}

const_iterator end() const {
KASSERT(_data);
KASSERT(_data || _size == 0);
return const_iterator(_data + _size);
}

Expand Down Expand Up @@ -341,7 +341,7 @@ template <typename T> class StaticArray {
}

void assign(const size_type count, const value_type value, const bool assign_parallel = true) {
KASSERT(_data);
KASSERT(_data || count == 0);

if (assign_parallel) {
const std::size_t step = std::max(count / std::thread::hardware_concurrency(), 1UL);
Expand Down

0 comments on commit 170f98a

Please sign in to comment.