Skip to content

Commit

Permalink
Remove non-const qualified ranges for fixed_size_layout (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan authored Apr 4, 2024
1 parent 8439242 commit 9a19935
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
18 changes: 0 additions & 18 deletions include/sparrow/fixed_size_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ namespace sparrow
using const_bitmap_range = std::ranges::subrange<const_bitmap_iterator>;
using const_value_range = std::ranges::subrange<const_value_iterator>;

using bitmap_range = std::ranges::subrange<bitmap_iterator>;
using value_range = std::ranges::subrange<value_iterator>;

using iterator = layout_iterator<self_type, false>;
using const_iterator = layout_iterator<self_type, true>;

Expand All @@ -86,9 +83,6 @@ namespace sparrow
const_iterator cbegin() const;
const_iterator cend() const;

bitmap_range bitmap();
value_range values();

const_bitmap_range bitmap() const;
const_value_range values() const;

Expand Down Expand Up @@ -191,18 +185,6 @@ namespace sparrow
return const_iterator(value_cend(), bitmap_cend());
}

template <class T>
auto fixed_size_layout<T>::bitmap() -> bitmap_range
{
return std::ranges::subrange(bitmap_begin(), bitmap_end());
}

template <class T>
auto fixed_size_layout<T>::values() -> value_range
{
return std::ranges::subrange(value_begin(), value_end());
}

template <class T>
auto fixed_size_layout<T>::bitmap() const -> const_bitmap_range
{
Expand Down
17 changes: 5 additions & 12 deletions test/test_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,20 @@ namespace sparrow
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_values = lt.values();
layout_test_type::value_iterator iter = lt_values.begin();
// TODO: Allow coercion of iterator to const_iterator.
// layout_test_type::const_value_iterator citer = lt_values.begin();
CHECK(iter < lt_values.end());
// CHECK(citer < lt_values.end());
layout_test_type::const_value_iterator citer = lt_values.begin();
CHECK(citer < lt_values.end());
}

TEST_CASE("value_iterator_equality")
{
layout_test_type lt(make_test_array_data(10, 1));
auto lt_values = lt.values();
layout_test_type::value_iterator iter = lt_values.begin();
// TODO: Allow coercion of iterator to const_iterator.
// layout_test_type::const_value_iterator citer = lt_values.begin();
layout_test_type::const_value_iterator citer = lt_values.begin();
for (std::size_t i = 0; i < lt.size(); ++i)
{
CHECK_EQ(*iter++, lt[i]);
// CHECK_EQ(*citer++, lt[i]);
CHECK_EQ(*citer++, lt[i]);
}
CHECK_EQ(iter, lt_values.end());
// CHECK_EQ(citer, lt_values.end());
CHECK_EQ(citer, lt_values.end());
}

TEST_CASE("iterator")
Expand Down

0 comments on commit 9a19935

Please sign in to comment.