Skip to content

Commit

Permalink
Removed non-const begin and counted_view range constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
OleErikPeistorpet committed Sep 29, 2023
1 parent 2493d4a commit 47294e5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion unit_test/view_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ TEST(viewTest, countedView)
#endif
{
oel::dynarray<int> i{1, 2};
oel::counted_view<oel::dynarray<int>::const_iterator> test = i;
auto test = view::counted(i.begin(), i.size());
EXPECT_EQ(i.size(), test.size());
EXPECT_EQ(1, test[0]);
EXPECT_EQ(2, test[1]);
Expand Down
9 changes: 1 addition & 8 deletions view/counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)


#include "../util.h"
#include "detail/misc.h"

/** @file
Expand All @@ -26,14 +25,8 @@ class counted_view

counted_view() = default;
constexpr counted_view(Iterator f, difference_type n) : _begin{std::move(f)}, _size{n} {}
//! Construct from range (lvalue) that knows its size, with matching iterator type
template< typename SizedRange,
enable_if< !std::is_base_of<counted_view, SizedRange>::value > = 0 // avoid being selected for copy
>
constexpr counted_view(SizedRange & r) : _begin(oel::adl_begin(r)), _size(oel::ssize(r)) {}

constexpr Iterator begin() { return _detail::MoveIfNotCopyable(_begin); }
constexpr Iterator begin() const OEL_ALWAYS_INLINE { return _begin; }
constexpr Iterator begin() { return _detail::MoveIfNotCopyable(_begin); }
//! Provided only if Iterator is random-access
template< typename I = Iterator,
enable_if< iter_is_random_access<I> > = 0
Expand Down
5 changes: 2 additions & 3 deletions view/subrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ class basic_view
basic_view() = default;
constexpr basic_view(Iterator f, Sentinel l) : _begin{std::move(f)}, _end{l} {}

constexpr Iterator begin() { return _detail::MoveIfNotCopyable(_begin); }
constexpr Iterator begin() const OEL_ALWAYS_INLINE { return _begin; }
constexpr Iterator begin() { return _detail::MoveIfNotCopyable(_begin); }

constexpr Sentinel end() const OEL_ALWAYS_INLINE { return _end; }
constexpr Sentinel end() const OEL_ALWAYS_INLINE { return _end; }

//! Provided only if begin() can be subtracted from end()
template< typename I = Iterator,
Expand Down

0 comments on commit 47294e5

Please sign in to comment.