Fix vector<bool> serialization for tar files and add unit tests

This commit is contained in:
Patrick Niklaus
2018-03-16 14:59:05 +00:00
parent cb31f9ec29
commit aaf39162a8
11 changed files with 210 additions and 108 deletions
+21 -1
View File
@@ -108,6 +108,15 @@ template <typename DataT> class vector_view
std::size_t size() const { return m_size; }
void resize(const size_t size) {
if (size > m_size)
{
throw util::exception("Trying to resize a view to a larger size.");
}
m_size = size;
}
bool empty() const { return 0 == size(); }
DataT &operator[](const unsigned index)
@@ -185,7 +194,18 @@ template <> class vector_view<bool>
return m_ptr[bucket] & (1u << offset);
}
void reset(unsigned *, std::size_t size) { m_size = size; }
void reset(unsigned * ptr, std::size_t size) {
m_ptr = ptr;
m_size = size;
}
void resize(const size_t size) {
if (size > m_size)
{
throw util::exception("Trying to resize a view to a larger size.");
}
m_size = size;
}
std::size_t size() const { return m_size; }