[libc++] [test] s/ContiguousView/MoveOnlyView/g. NFCI.

The unique (ha!) thing about this range type is that it's move-only.
Its contiguity is unsurprising (most of our test ranges are contiguous).
Discussed in D111231 but committed separately for clarity.
This commit is contained in:
Arthur O'Dwyer 2021-10-06 16:40:08 -04:00
parent 3666dd795d
commit 610ac8dbcc
37 changed files with 135 additions and 135 deletions

View File

@ -40,11 +40,11 @@ constexpr bool test() {
}
{
ContiguousView view{buf, buf + 8};
std::ranges::common_view<ContiguousView> common(std::move(view));
MoveOnlyView view{buf, buf + 8};
std::ranges::common_view<MoveOnlyView> common(std::move(view));
assert(std::move(common).base().begin_ == buf);
ASSERT_SAME_TYPE(decltype(std::move(common).base()), ContiguousView);
ASSERT_SAME_TYPE(decltype(std::move(common).base()), MoveOnlyView);
static_assert(!hasLValueQualifiedBase(common));
}

View File

@ -79,8 +79,8 @@ int main(int, char**) {
}
{
ContiguousView view{buf, buf + 8};
std::ranges::common_view<ContiguousView> common(std::move(view));
MoveOnlyView view{buf, buf + 8};
std::ranges::common_view<MoveOnlyView> common(std::move(view));
using CommonIter = std::common_iterator<int*, sentinel_wrapper<int*>>;
std::same_as<CommonIter> auto begin = common.begin();
assert(begin == std::ranges::begin(view));

View File

@ -21,7 +21,7 @@
#include "types.h"
int main(int, char**) {
static_assert(!std::default_initializable<std::ranges::common_view<ContiguousView>>);
static_assert(!std::default_initializable<std::ranges::common_view<MoveOnlyView>>);
static_assert( std::default_initializable<std::ranges::common_view<DefaultConstructibleView>>);
std::ranges::common_view<DefaultConstructibleView> common;

View File

@ -24,8 +24,8 @@ constexpr bool test() {
int buf[8] = {1, 2, 3, 4, 5, 6, 7, 8};
{
ContiguousView view{buf, buf + 8};
std::ranges::common_view<ContiguousView> common(std::move(view));
MoveOnlyView view{buf, buf + 8};
std::ranges::common_view<MoveOnlyView> common(std::move(view));
assert(std::move(common).base().begin_ == buf);
}
@ -45,8 +45,8 @@ int main(int, char**) {
// Can't compare common_iterator inside constexpr
{
int buf[8] = {1, 2, 3, 4, 5, 6, 7, 8};
ContiguousView view{buf, buf + 8};
std::ranges::common_view<ContiguousView> const common(std::move(view));
MoveOnlyView view{buf, buf + 8};
std::ranges::common_view<MoveOnlyView> const common(std::move(view));
assert(common.begin() == buf);
}

View File

@ -23,18 +23,18 @@ struct DefaultConstructibleView : std::ranges::view_base {
static_assert(std::ranges::view<DefaultConstructibleView>);
static_assert(std::default_initializable<DefaultConstructibleView>);
struct ContiguousView : std::ranges::view_base {
struct MoveOnlyView : std::ranges::view_base {
int* begin_;
int* end_;
constexpr explicit ContiguousView(int* b, int* e) : begin_(b), end_(e) { }
constexpr ContiguousView(ContiguousView&&) = default;
constexpr ContiguousView& operator=(ContiguousView&&) = default;
constexpr explicit MoveOnlyView(int* b, int* e) : begin_(b), end_(e) { }
constexpr MoveOnlyView(MoveOnlyView&&) = default;
constexpr MoveOnlyView& operator=(MoveOnlyView&&) = default;
constexpr int *begin() const { return begin_; }
constexpr auto end() const { return sentinel_wrapper<int*>(end_); }
};
static_assert( std::ranges::view<ContiguousView>);
static_assert( std::ranges::contiguous_range<ContiguousView>);
static_assert(!std::copyable<ContiguousView>);
static_assert( std::ranges::view<MoveOnlyView>);
static_assert( std::ranges::contiguous_range<MoveOnlyView>);
static_assert(!std::copyable<MoveOnlyView>);
struct CopyableView : std::ranges::view_base {
int* begin_;

View File

@ -19,12 +19,12 @@
#include "types.h"
constexpr bool test() {
std::ranges::drop_view<ContiguousView> dropView1;
std::ranges::drop_view<MoveOnlyView> dropView1;
auto base1 = std::move(dropView1).base();
assert(std::ranges::begin(base1) == globalBuff);
// Note: we should *not* drop two elements here.
std::ranges::drop_view<ContiguousView> dropView2(ContiguousView{4}, 2);
std::ranges::drop_view<MoveOnlyView> dropView2(MoveOnlyView{4}, 2);
auto base2 = std::move(dropView2).base();
assert(std::ranges::begin(base2) == globalBuff + 4);

View File

@ -26,7 +26,7 @@ concept BeginInvocable = requires(std::ranges::drop_view<T> t) { t.begin(); };
constexpr bool test() {
// random_access_range<const V> && sized_range<const V>
std::ranges::drop_view dropView1(ContiguousView(), 4);
std::ranges::drop_view dropView1(MoveOnlyView(), 4);
assert(dropView1.begin() == globalBuff + 4);
// !random_access_range<const V>
@ -38,19 +38,19 @@ constexpr bool test() {
assert(dropView3.begin().base() == globalBuff + 4);
// random_access_range<const V> && sized_range<const V>
std::ranges::drop_view dropView4(ContiguousView(), 8);
std::ranges::drop_view dropView4(MoveOnlyView(), 8);
assert(dropView4.begin() == globalBuff + 8);
// random_access_range<const V> && sized_range<const V>
std::ranges::drop_view dropView5(ContiguousView(), 0);
std::ranges::drop_view dropView5(MoveOnlyView(), 0);
assert(dropView5.begin() == globalBuff);
// random_access_range<const V> && sized_range<const V>
const std::ranges::drop_view dropView6(ContiguousView(), 0);
const std::ranges::drop_view dropView6(MoveOnlyView(), 0);
assert(dropView6.begin() == globalBuff);
// random_access_range<const V> && sized_range<const V>
std::ranges::drop_view dropView7(ContiguousView(), 10);
std::ranges::drop_view dropView7(MoveOnlyView(), 10);
assert(dropView7.begin() == globalBuff + 8);
CountedView view8;

View File

@ -20,7 +20,7 @@
namespace ranges = std::ranges;
static_assert(std::same_as<decltype(ranges::drop_view(ContiguousView(), 0)), ranges::drop_view<ContiguousView>>);
static_assert(std::same_as<decltype(ranges::drop_view(MoveOnlyView(), 0)), ranges::drop_view<MoveOnlyView>>);
static_assert(std::same_as<decltype(ranges::drop_view(CopyableView(), 0)), ranges::drop_view<CopyableView>>);
static_assert(std::same_as<decltype(ranges::drop_view(ForwardView(), 0)), ranges::drop_view<ForwardView>>);
static_assert(std::same_as<decltype(ranges::drop_view(InputView(), 0)), ranges::drop_view<InputView>>);

View File

@ -18,7 +18,7 @@
#include "types.h"
constexpr bool test() {
std::ranges::drop_view<ContiguousView> dropView1;
std::ranges::drop_view<MoveOnlyView> dropView1;
assert(std::ranges::begin(dropView1) == globalBuff);
static_assert( std::is_default_constructible_v<std::ranges::drop_view<ForwardView>>);

View File

@ -18,7 +18,7 @@
#include "types.h"
constexpr bool test() {
std::ranges::drop_view dropView1(ContiguousView(), 4);
std::ranges::drop_view dropView1(MoveOnlyView(), 4);
assert(dropView1.size() == 4);
assert(dropView1.begin() == globalBuff + 4);

View File

@ -22,7 +22,7 @@
constexpr bool test() {
// range<const V>
std::ranges::drop_view dropView1(ContiguousView(), 4);
std::ranges::drop_view dropView1(MoveOnlyView(), 4);
assert(dropView1.end() == globalBuff + 8);
// !simple-view<V>
@ -30,7 +30,7 @@ constexpr bool test() {
assert(dropView2.end() == globalBuff + 8);
// range<const V>
const std::ranges::drop_view dropView3(ContiguousView(), 0);
const std::ranges::drop_view dropView3(MoveOnlyView(), 0);
assert(dropView3.end() == globalBuff + 8);
// !simple-view<V>
@ -38,7 +38,7 @@ constexpr bool test() {
assert(dropView4.end() == globalBuff + 8);
// range<const V>
std::ranges::drop_view dropView5(ContiguousView(), 10);
std::ranges::drop_view dropView5(MoveOnlyView(), 10);
assert(dropView5.end() == globalBuff + 8);
return true;

View File

@ -28,10 +28,10 @@
template<class T>
concept ValidDropView = requires { typename std::ranges::drop_view<T>; };
static_assert( ValidDropView<ContiguousView>);
static_assert( ValidDropView<MoveOnlyView>);
static_assert(!ValidDropView<Range>);
static_assert(!std::ranges::enable_borrowed_range<std::ranges::drop_view<ContiguousView>>);
static_assert(!std::ranges::enable_borrowed_range<std::ranges::drop_view<MoveOnlyView>>);
static_assert( std::ranges::enable_borrowed_range<std::ranges::drop_view<BorrowableView>>);
template<std::ranges::view View>

View File

@ -25,19 +25,19 @@ concept SizeInvocable = requires(std::ranges::drop_view<T> t) { t.size(); };
constexpr bool test() {
// sized_range<V>
std::ranges::drop_view dropView1(ContiguousView(), 4);
std::ranges::drop_view dropView1(MoveOnlyView(), 4);
assert(dropView1.size() == 4);
// sized_range<V>
std::ranges::drop_view dropView2(ContiguousView(), 0);
std::ranges::drop_view dropView2(MoveOnlyView(), 0);
assert(dropView2.size() == 8);
// sized_range<const V>
const std::ranges::drop_view dropView3(ContiguousView(), 8);
const std::ranges::drop_view dropView3(MoveOnlyView(), 8);
assert(dropView3.size() == 0);
// sized_range<const V>
const std::ranges::drop_view dropView4(ContiguousView(), 10);
const std::ranges::drop_view dropView4(MoveOnlyView(), 10);
assert(dropView4.size() == 0);
// Because ForwardView is not a sized_range.

View File

@ -14,17 +14,17 @@
int globalBuff[8];
struct ContiguousView : std::ranges::view_base {
struct MoveOnlyView : std::ranges::view_base {
int start_;
constexpr explicit ContiguousView(int start = 0) : start_(start) {}
constexpr ContiguousView(ContiguousView&&) = default;
constexpr ContiguousView& operator=(ContiguousView&&) = default;
constexpr explicit MoveOnlyView(int start = 0) : start_(start) {}
constexpr MoveOnlyView(MoveOnlyView&&) = default;
constexpr MoveOnlyView& operator=(MoveOnlyView&&) = default;
constexpr int *begin() const { return globalBuff + start_; }
constexpr int *end() const { return globalBuff + 8; }
};
static_assert( std::ranges::view<ContiguousView>);
static_assert( std::ranges::contiguous_range<ContiguousView>);
static_assert(!std::copyable<ContiguousView>);
static_assert( std::ranges::view<MoveOnlyView>);
static_assert( std::ranges::contiguous_range<MoveOnlyView>);
static_assert(!std::copyable<MoveOnlyView>);
struct CopyableView : std::ranges::view_base {
int start_;

View File

@ -38,10 +38,10 @@ constexpr bool test() {
}
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 1);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 1);
assert(std::move(tv).base().ptr_ == buffer);
ASSERT_SAME_TYPE(decltype(std::move(tv).base()), ContiguousView);
ASSERT_SAME_TYPE(decltype(std::move(tv).base()), MoveOnlyView);
static_assert(!hasLValueQualifiedBase(tv));
}

View File

@ -52,13 +52,13 @@ constexpr bool test() {
// !sized_range
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.begin() == std::counted_iterator<int*>(buffer, 4));
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
}
{
const std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.begin() == std::counted_iterator<int*>(buffer, 4));
ASSERT_SAME_TYPE(decltype(tv.begin()), std::counted_iterator<int*>);
}

View File

@ -30,7 +30,7 @@ constexpr bool test() {
}
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 1);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 1);
assert(std::move(tv).base().ptr_ == buffer);
assert(std::ranges::next(tv.begin(), 1) == tv.end()); // Checking we have correct size.
}

View File

@ -52,7 +52,7 @@ constexpr bool test() {
// !sized_range
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.end() == std::ranges::next(tv.begin(), 4));
// The <sentinel> type.
@ -61,7 +61,7 @@ constexpr bool test() {
}
{
const std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 5);
const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 5);
assert(tv.end() == std::ranges::next(tv.begin(), 5));
}

View File

@ -27,13 +27,13 @@ constexpr bool test() {
auto sw = sentinel_wrapper<int *>(buffer + 8); // Note: not 4, but that's OK.
{
const std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.end().base().base() == sw.base());
ASSERT_SAME_TYPE(decltype(tv.end().base()), sentinel_wrapper<int *>);
}
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.end().base().base() == sw.base());
ASSERT_SAME_TYPE(decltype(tv.end().base()), sentinel_wrapper<int *>);
}

View File

@ -27,13 +27,13 @@ constexpr bool test() {
{
// Test the default ctor.
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(decltype(tv.end()){} == std::ranges::next(tv.begin(), 4));
}
{
std::ranges::take_view<ContiguousView> nonConst(ContiguousView{buffer}, 5);
const std::ranges::take_view<ContiguousView> tvConst(ContiguousView{buffer}, 5);
std::ranges::take_view<MoveOnlyView> nonConst(MoveOnlyView{buffer}, 5);
const std::ranges::take_view<MoveOnlyView> tvConst(MoveOnlyView{buffer}, 5);
auto sent1 = nonConst.end();
// Convert to const. Note, we cannot go the other way.
std::remove_cv_t<decltype(tvConst.end())> sent2 = sent1;

View File

@ -27,21 +27,21 @@ constexpr bool test() {
{
{
const std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
const std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.end() == std::ranges::next(tv.begin(), 4));
assert(std::ranges::next(tv.begin(), 4) == tv.end());
}
{
std::ranges::take_view<ContiguousView> tv(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tv(MoveOnlyView{buffer}, 4);
assert(tv.end() == std::ranges::next(tv.begin(), 4));
assert(std::ranges::next(tv.begin(), 4) == tv.end());
}
}
{
std::ranges::take_view<ContiguousView> tvNonConst(ContiguousView{buffer}, 4);
const std::ranges::take_view<ContiguousView> tvConst(ContiguousView{buffer}, 4);
std::ranges::take_view<MoveOnlyView> tvNonConst(MoveOnlyView{buffer}, 4);
const std::ranges::take_view<MoveOnlyView> tvConst(MoveOnlyView{buffer}, 4);
assert(tvNonConst.end() == std::ranges::next(tvConst.begin(), 4));
assert(std::ranges::next(tvConst.begin(), 4) == tvNonConst.end());
}

View File

@ -7,19 +7,19 @@
#include "test_iterators.h"
#include "test_range.h"
struct ContiguousView : std::ranges::view_base {
struct MoveOnlyView : std::ranges::view_base {
int *ptr_;
constexpr explicit ContiguousView(int* ptr) : ptr_(ptr) {}
ContiguousView(ContiguousView&&) = default;
ContiguousView& operator=(ContiguousView&&) = default;
constexpr explicit MoveOnlyView(int* ptr) : ptr_(ptr) {}
MoveOnlyView(MoveOnlyView&&) = default;
MoveOnlyView& operator=(MoveOnlyView&&) = default;
constexpr int* begin() const {return ptr_;}
constexpr sentinel_wrapper<int*> end() const {return sentinel_wrapper<int*>{ptr_ + 8};}
};
static_assert( std::ranges::view<ContiguousView>);
static_assert( std::ranges::contiguous_range<ContiguousView>);
static_assert(!std::copyable<ContiguousView>);
static_assert( std::ranges::view<MoveOnlyView>);
static_assert( std::ranges::contiguous_range<MoveOnlyView>);
static_assert(!std::copyable<MoveOnlyView>);
struct CopyableView : std::ranges::view_base {
int *ptr_;

View File

@ -39,8 +39,8 @@ constexpr bool test() {
// Test `views::transform(f)(v)`
{
{
using Result = std::ranges::transform_view<ContiguousView, PlusOne>;
std::same_as<Result> auto result = std::views::transform(PlusOne{})(ContiguousView{buff});
using Result = std::ranges::transform_view<MoveOnlyView, PlusOne>;
std::same_as<Result> auto result = std::views::transform(PlusOne{})(MoveOnlyView{buff});
assert(result.begin().base() == buff);
assert(result[0] == 1);
assert(result[1] == 2);
@ -48,8 +48,8 @@ constexpr bool test() {
}
{
auto const partial = std::views::transform(PlusOne{});
using Result = std::ranges::transform_view<ContiguousView, PlusOne>;
std::same_as<Result> auto result = partial(ContiguousView{buff});
using Result = std::ranges::transform_view<MoveOnlyView, PlusOne>;
std::same_as<Result> auto result = partial(MoveOnlyView{buff});
assert(result.begin().base() == buff);
assert(result[0] == 1);
assert(result[1] == 2);
@ -60,8 +60,8 @@ constexpr bool test() {
// Test `v | views::transform(f)`
{
{
using Result = std::ranges::transform_view<ContiguousView, PlusOne>;
std::same_as<Result> auto result = ContiguousView{buff} | std::views::transform(PlusOne{});
using Result = std::ranges::transform_view<MoveOnlyView, PlusOne>;
std::same_as<Result> auto result = MoveOnlyView{buff} | std::views::transform(PlusOne{});
assert(result.begin().base() == buff);
assert(result[0] == 1);
assert(result[1] == 2);
@ -69,8 +69,8 @@ constexpr bool test() {
}
{
auto const partial = std::views::transform(PlusOne{});
using Result = std::ranges::transform_view<ContiguousView, PlusOne>;
std::same_as<Result> auto result = ContiguousView{buff} | partial;
using Result = std::ranges::transform_view<MoveOnlyView, PlusOne>;
std::same_as<Result> auto result = MoveOnlyView{buff} | partial;
assert(result.begin().base() == buff);
assert(result[0] == 1);
assert(result[1] == 2);
@ -80,8 +80,8 @@ constexpr bool test() {
// Test `views::transform(v, f)`
{
using Result = std::ranges::transform_view<ContiguousView, PlusOne>;
std::same_as<Result> auto result = std::views::transform(ContiguousView{buff}, PlusOne{});
using Result = std::ranges::transform_view<MoveOnlyView, PlusOne>;
std::same_as<Result> auto result = std::views::transform(MoveOnlyView{buff}, PlusOne{});
assert(result.begin().base() == buff);
assert(result[0] == 1);
assert(result[1] == 2);
@ -101,8 +101,8 @@ constexpr bool test() {
// Test `adaptor | views::transform(f)`
{
{
using Result = std::ranges::transform_view<std::ranges::transform_view<ContiguousView, PlusOne>, TimesTwo>;
std::same_as<Result> auto result = ContiguousView{buff} | std::views::transform(PlusOne{}) | std::views::transform(TimesTwo{});
using Result = std::ranges::transform_view<std::ranges::transform_view<MoveOnlyView, PlusOne>, TimesTwo>;
std::same_as<Result> auto result = MoveOnlyView{buff} | std::views::transform(PlusOne{}) | std::views::transform(TimesTwo{});
assert(result.begin().base().base() == buff);
assert(result[0] == 2);
assert(result[1] == 4);
@ -110,8 +110,8 @@ constexpr bool test() {
}
{
auto const partial = std::views::transform(PlusOne{}) | std::views::transform(TimesTwo{});
using Result = std::ranges::transform_view<std::ranges::transform_view<ContiguousView, PlusOne>, TimesTwo>;
std::same_as<Result> auto result = ContiguousView{buff} | partial;
using Result = std::ranges::transform_view<std::ranges::transform_view<MoveOnlyView, PlusOne>, TimesTwo>;
std::same_as<Result> auto result = MoveOnlyView{buff} | partial;
assert(result.begin().base().base() == buff);
assert(result[0] == 2);
assert(result[1] == 4);
@ -124,15 +124,15 @@ constexpr bool test() {
struct NotAView { };
struct NotInvocable { };
static_assert(!CanBePiped<ContiguousView, decltype(std::views::transform)>);
static_assert( CanBePiped<ContiguousView, decltype(std::views::transform(PlusOne{}))>);
static_assert(!CanBePiped<MoveOnlyView, decltype(std::views::transform)>);
static_assert( CanBePiped<MoveOnlyView, decltype(std::views::transform(PlusOne{}))>);
static_assert(!CanBePiped<NotAView, decltype(std::views::transform(PlusOne{}))>);
static_assert(!CanBePiped<ContiguousView, decltype(std::views::transform(NotInvocable{}))>);
static_assert(!CanBePiped<MoveOnlyView, decltype(std::views::transform(NotInvocable{}))>);
static_assert(!std::is_invocable_v<decltype(std::views::transform)>);
static_assert(!std::is_invocable_v<decltype(std::views::transform), PlusOne, ContiguousView>);
static_assert( std::is_invocable_v<decltype(std::views::transform), ContiguousView, PlusOne>);
static_assert(!std::is_invocable_v<decltype(std::views::transform), ContiguousView, PlusOne, PlusOne>);
static_assert(!std::is_invocable_v<decltype(std::views::transform), PlusOne, MoveOnlyView>);
static_assert( std::is_invocable_v<decltype(std::views::transform), MoveOnlyView, PlusOne>);
static_assert(!std::is_invocable_v<decltype(std::views::transform), MoveOnlyView, PlusOne, PlusOne>);
static_assert(!std::is_invocable_v<decltype(std::views::transform), NonCopyableFunction>);
}

View File

@ -20,9 +20,9 @@
constexpr bool test() {
{
std::ranges::transform_view<ContiguousView, PlusOne> transformView;
ContiguousView base = std::move(transformView).base();
ASSERT_SAME_TYPE(ContiguousView, decltype(std::move(transformView).base()));
std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
MoveOnlyView base = std::move(transformView).base();
ASSERT_SAME_TYPE(MoveOnlyView, decltype(std::move(transformView).base()));
assert(std::ranges::begin(base) == globalBuff);
}

View File

@ -27,7 +27,7 @@ constexpr bool test() {
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
{
std::ranges::transform_view transformView(ContiguousView{buff}, PlusOneMutable{});
std::ranges::transform_view transformView(MoveOnlyView{buff}, PlusOneMutable{});
assert(transformView.begin().base() == buff);
assert(*transformView.begin() == 1);
}
@ -45,11 +45,11 @@ constexpr bool test() {
}
{
const std::ranges::transform_view transformView(ContiguousView{buff}, PlusOne{});
const std::ranges::transform_view transformView(MoveOnlyView{buff}, PlusOne{});
assert(*transformView.begin() == 1);
}
static_assert(!BeginInvocable<const std::ranges::transform_view<ContiguousView, PlusOneMutable>>);
static_assert(!BeginInvocable<const std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>);
return true;
}

View File

@ -32,7 +32,7 @@ concept EndIsIter = requires(T t) { ++t.end(); };
constexpr bool test() {
{
std::ranges::transform_view transformView(ContiguousView{}, PlusOneMutable{});
std::ranges::transform_view transformView(MoveOnlyView{}, PlusOneMutable{});
assert(transformView.end().base() == globalBuff + 8);
}
@ -47,21 +47,21 @@ constexpr bool test() {
}
{
const std::ranges::transform_view transformView(ContiguousView{}, PlusOne{});
const std::ranges::transform_view transformView(MoveOnlyView{}, PlusOne{});
assert(transformView.end().base() == globalBuff + 8);
}
static_assert(!EndInvocable<const std::ranges::transform_view<ContiguousView, PlusOneMutable>>);
static_assert( EndInvocable< std::ranges::transform_view<ContiguousView, PlusOneMutable>>);
static_assert( EndInvocable<const std::ranges::transform_view<ContiguousView, PlusOne>>);
static_assert(!EndInvocable<const std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>);
static_assert( EndInvocable< std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>);
static_assert( EndInvocable<const std::ranges::transform_view<MoveOnlyView, PlusOne>>);
static_assert(!EndInvocable<const std::ranges::transform_view<InputView, PlusOneMutable>>);
static_assert( EndInvocable< std::ranges::transform_view<InputView, PlusOneMutable>>);
static_assert( EndInvocable<const std::ranges::transform_view<InputView, PlusOne>>);
static_assert(!EndIsIter<const std::ranges::transform_view<InputView, PlusOne>>);
static_assert(!EndIsIter< std::ranges::transform_view<InputView, PlusOneMutable>>);
static_assert( EndIsIter<const std::ranges::transform_view<ContiguousView, PlusOne>>);
static_assert( EndIsIter< std::ranges::transform_view<ContiguousView, PlusOneMutable>>);
static_assert( EndIsIter<const std::ranges::transform_view<MoveOnlyView, PlusOne>>);
static_assert( EndIsIter< std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>);
return true;
}

View File

@ -32,9 +32,9 @@ template<class T, class F>
concept ValidTransformView = requires { typename std::ranges::transform_view<T, F>; };
struct BadFunction { };
static_assert( ValidTransformView<ContiguousView, PlusOne>);
static_assert( ValidTransformView<MoveOnlyView, PlusOne>);
static_assert(!ValidTransformView<Range, PlusOne>);
static_assert(!ValidTransformView<ContiguousView, BadFunction>);
static_assert(!ValidTransformView<MoveOnlyView, BadFunction>);
template<std::ranges::range R>
auto toUpper(R range) {

View File

@ -18,7 +18,7 @@
#include "../types.h"
constexpr bool test() {
std::ranges::transform_view<ContiguousView, PlusOne> transformView;
std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
auto iter = std::move(transformView).begin();
assert((++iter).base() == globalBuff + 1);

View File

@ -24,7 +24,7 @@ concept BaseInvocable = requires(std::ranges::iterator_t<std::ranges::transform_
constexpr bool test() {
{
std::ranges::transform_view<ContiguousView, PlusOneMutable> transformView;
std::ranges::transform_view<MoveOnlyView, PlusOneMutable> transformView;
auto iter = std::move(transformView).begin();
ASSERT_SAME_TYPE(int*, decltype(iter.base()));
assert(iter.base() == globalBuff);

View File

@ -57,15 +57,15 @@ struct IterNoDefaultInitView : std::ranges::view_base {
};
constexpr bool test() {
std::ranges::transform_view<ContiguousView, PlusOne> transformView;
std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
auto iter = std::move(transformView).begin();
std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOne>> i2(iter);
std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOne>> i2(iter);
(void)i2;
std::ranges::iterator_t<const std::ranges::transform_view<ContiguousView, PlusOne>> constIter(iter);
std::ranges::iterator_t<const std::ranges::transform_view<MoveOnlyView, PlusOne>> constIter(iter);
(void)constIter;
static_assert( std::default_initializable<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOne>>>);
static_assert( std::default_initializable<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOne>>>);
static_assert(!std::default_initializable<std::ranges::iterator_t<std::ranges::transform_view<IterNoDefaultInitView, PlusOne>>>);
return true;

View File

@ -20,40 +20,40 @@
int main(int, char**) {
{
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, PlusOne>;
View transformView(ContiguousView{buff}, PlusOne{});
using View = std::ranges::transform_view<MoveOnlyView, PlusOne>;
View transformView(MoveOnlyView{buff}, PlusOne{});
assert(*transformView.begin() == 1);
static_assert(!noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int, decltype(*std::declval<View>().begin()));
}
{
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, PlusOneMutable>;
View transformView(ContiguousView{buff}, PlusOneMutable{});
using View = std::ranges::transform_view<MoveOnlyView, PlusOneMutable>;
View transformView(MoveOnlyView{buff}, PlusOneMutable{});
assert(*transformView.begin() == 1);
static_assert(!noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int, decltype(*std::declval<View>().begin()));
}
{
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, PlusOneNoexcept>;
View transformView(ContiguousView{buff}, PlusOneNoexcept{});
using View = std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>;
View transformView(MoveOnlyView{buff}, PlusOneNoexcept{});
assert(*transformView.begin() == 1);
static_assert(noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int, decltype(*std::declval<View>().begin()));
}
{
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, Increment>;
View transformView(ContiguousView{buff}, Increment{});
using View = std::ranges::transform_view<MoveOnlyView, Increment>;
View transformView(MoveOnlyView{buff}, Increment{});
assert(*transformView.begin() == 1);
static_assert(!noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int&, decltype(*std::declval<View>().begin()));
}
{
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, IncrementRvalueRef>;
View transformView(ContiguousView{buff}, IncrementRvalueRef{});
using View = std::ranges::transform_view<MoveOnlyView, IncrementRvalueRef>;
View transformView(MoveOnlyView{buff}, IncrementRvalueRef{});
assert(*transformView.begin() == 1);
static_assert(!noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int&&, decltype(*std::declval<View>().begin()));

View File

@ -21,7 +21,7 @@ constexpr bool test() {
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
{
std::ranges::transform_view transformView(ContiguousView{buff}, PlusOneMutable{});
std::ranges::transform_view transformView(MoveOnlyView{buff}, PlusOneMutable{});
auto iter = transformView.begin();
static_assert(!noexcept(std::ranges::iter_move(iter)));
@ -34,9 +34,9 @@ constexpr bool test() {
{
static_assert( noexcept(std::ranges::iter_move(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneNoexcept>>&>())));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>>&>())));
static_assert(!noexcept(std::ranges::iter_move(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneMutable>>&>())));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>&>())));
}
return true;

View File

@ -18,9 +18,9 @@
#include "../types.h"
constexpr bool test() {
std::ranges::transform_view<ContiguousView, PlusOneMutable> transformView1;
std::ranges::transform_view<MoveOnlyView, PlusOneMutable> transformView1;
auto iter1 = std::move(transformView1).begin();
std::ranges::transform_view<ContiguousView, PlusOneMutable> transformView2;
std::ranges::transform_view<MoveOnlyView, PlusOneMutable> transformView2;
auto iter2 = std::move(transformView2).begin();
iter1 += 4;
assert((iter1 + 1).base() == globalBuff + 5);

View File

@ -19,15 +19,15 @@
constexpr bool test() {
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
std::ranges::transform_view transformView1(ContiguousView{buff}, PlusOneMutable{});
std::ranges::transform_view transformView1(MoveOnlyView{buff}, PlusOneMutable{});
auto iter1 = std::move(transformView1).begin() + 1;
assert(iter1[0] == 2);
assert(iter1[4] == 6);
static_assert(!noexcept(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneMutable>>>()[0]));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>>()[0]));
static_assert( noexcept(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneNoexcept>>>()[0]));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>>>()[0]));
ASSERT_SAME_TYPE(
int,

View File

@ -29,7 +29,7 @@ constexpr bool test() {
static_assert(std::same_as<std::iterator_traits<int*>::iterator_concept, std::contiguous_iterator_tag>);
static_assert(std::same_as<std::iterator_traits<int*>::iterator_category, std::random_access_iterator_tag>);
using TView = std::ranges::transform_view<ContiguousView, Increment>;
using TView = std::ranges::transform_view<MoveOnlyView, Increment>;
using TIter = std::ranges::iterator_t<TView>;
static_assert(std::same_as<typename TIter::iterator_concept, std::random_access_iterator_tag>);
static_assert(std::same_as<typename TIter::iterator_category, std::random_access_iterator_tag>);

View File

@ -23,12 +23,12 @@ concept SizeInvocable = requires(T t) { t.size(); };
constexpr bool test() {
{
std::ranges::transform_view transformView(ContiguousView{}, PlusOne{});
std::ranges::transform_view transformView(MoveOnlyView{}, PlusOne{});
assert(transformView.size() == 8);
}
{
const std::ranges::transform_view transformView(ContiguousView{globalBuff, 4}, PlusOne{});
const std::ranges::transform_view transformView(MoveOnlyView{globalBuff, 4}, PlusOne{});
assert(transformView.size() == 4);
}

View File

@ -15,18 +15,18 @@
int globalBuff[8] = {0,1,2,3,4,5,6,7};
struct ContiguousView : std::ranges::view_base {
struct MoveOnlyView : std::ranges::view_base {
int start_;
int *ptr_;
constexpr explicit ContiguousView(int* ptr = globalBuff, int start = 0) : start_(start), ptr_(ptr) {}
constexpr ContiguousView(ContiguousView&&) = default;
constexpr ContiguousView& operator=(ContiguousView&&) = default;
constexpr explicit MoveOnlyView(int* ptr = globalBuff, int start = 0) : start_(start), ptr_(ptr) {}
constexpr MoveOnlyView(MoveOnlyView&&) = default;
constexpr MoveOnlyView& operator=(MoveOnlyView&&) = default;
constexpr int *begin() const { return ptr_ + start_; }
constexpr int *end() const { return ptr_ + 8; }
};
static_assert( std::ranges::view<ContiguousView>);
static_assert( std::ranges::contiguous_range<ContiguousView>);
static_assert(!std::copyable<ContiguousView>);
static_assert( std::ranges::view<MoveOnlyView>);
static_assert( std::ranges::contiguous_range<MoveOnlyView>);
static_assert(!std::copyable<MoveOnlyView>);
struct CopyableView : std::ranges::view_base {
int start_;