[libc++][NFC] Refactor tests for transform_view

Adjust the names of helper function objects to represent better what
they do, as suggested in the review of D107098.
This commit is contained in:
Louis Dionne 2021-08-17 09:20:24 -04:00
parent 52e0cf9d61
commit 9de882fdbf
18 changed files with 117 additions and 98 deletions

View File

@ -20,14 +20,14 @@
constexpr bool test() {
{
std::ranges::transform_view<ContiguousView, Increment> transformView;
std::ranges::transform_view<ContiguousView, PlusOne> transformView;
ContiguousView base = std::move(transformView).base();
ASSERT_SAME_TYPE(ContiguousView, decltype(std::move(transformView).base()));
assert(std::ranges::begin(base) == globalBuff);
}
{
std::ranges::transform_view<CopyableView, Increment> transformView;
std::ranges::transform_view<CopyableView, PlusOne> transformView;
CopyableView base1 = transformView.base();
ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
assert(std::ranges::begin(base1) == globalBuff);
@ -38,7 +38,7 @@ constexpr bool test() {
}
{
const std::ranges::transform_view<CopyableView, Increment> transformView;
const std::ranges::transform_view<CopyableView, PlusOne> transformView;
const CopyableView base1 = transformView.base();
ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
assert(std::ranges::begin(base1) == globalBuff);

View File

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

View File

@ -18,9 +18,9 @@
#include "test_macros.h"
#include "types.h"
static_assert(std::same_as<decltype(std::ranges::transform_view(InputView(), Increment())),
std::ranges::transform_view<InputView, Increment>>);
static_assert(std::same_as<decltype(std::ranges::transform_view(std::declval<ForwardRange&>(), Increment())),
std::ranges::transform_view<std::ranges::ref_view<ForwardRange>, Increment>>);
static_assert(std::same_as<decltype(std::ranges::transform_view(BorrowableRange(), Increment())),
std::ranges::transform_view<std::ranges::subrange<int*>, Increment>>);
static_assert(std::same_as<decltype(std::ranges::transform_view(InputView(), PlusOne())),
std::ranges::transform_view<InputView, PlusOne>>);
static_assert(std::same_as<decltype(std::ranges::transform_view(std::declval<ForwardRange&>(), PlusOne())),
std::ranges::transform_view<std::ranges::ref_view<ForwardRange>, PlusOne>>);
static_assert(std::same_as<decltype(std::ranges::transform_view(BorrowableRange(), PlusOne())),
std::ranges::transform_view<std::ranges::subrange<int*>, PlusOne>>);

View File

@ -32,36 +32,36 @@ concept EndIsIter = requires(T t) { ++t.end(); };
constexpr bool test() {
{
std::ranges::transform_view transformView(ContiguousView{}, Increment{});
std::ranges::transform_view transformView(ContiguousView{}, PlusOneMutable{});
assert(transformView.end().base() == globalBuff + 8);
}
{
std::ranges::transform_view transformView(ForwardView{}, Increment{});
std::ranges::transform_view transformView(ForwardView{}, PlusOneMutable{});
assert(transformView.end().base().base() == globalBuff + 8);
}
{
std::ranges::transform_view transformView(InputView{}, Increment{});
std::ranges::transform_view transformView(InputView{}, PlusOneMutable{});
assert(transformView.end().base() == globalBuff + 8);
}
{
const std::ranges::transform_view transformView(ContiguousView{}, IncrementConst{});
const std::ranges::transform_view transformView(ContiguousView{}, PlusOne{});
assert(transformView.end().base() == globalBuff + 8);
}
static_assert(!EndInvocable<const std::ranges::transform_view<ContiguousView, Increment>>);
static_assert( EndInvocable< std::ranges::transform_view<ContiguousView, Increment>>);
static_assert( EndInvocable<const std::ranges::transform_view<ContiguousView, IncrementConst>>);
static_assert(!EndInvocable<const std::ranges::transform_view<InputView, Increment>>);
static_assert( EndInvocable< std::ranges::transform_view<InputView, Increment>>);
static_assert( EndInvocable<const std::ranges::transform_view<InputView, IncrementConst>>);
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<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, IncrementConst>>);
static_assert(!EndIsIter< std::ranges::transform_view<InputView, Increment>>);
static_assert( EndIsIter<const std::ranges::transform_view<ContiguousView, IncrementConst>>);
static_assert( EndIsIter< std::ranges::transform_view<ContiguousView, Increment>>);
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>>);
return true;
}

View File

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

View File

@ -18,7 +18,7 @@
#include "../types.h"
constexpr bool test() {
std::ranges::transform_view<ContiguousView, Increment> transformView;
std::ranges::transform_view<ContiguousView, PlusOne> transformView;
auto iter = std::move(transformView).begin();
assert((++iter).base() == globalBuff + 1);
@ -31,7 +31,7 @@ constexpr bool test() {
// Check that decltype(InputIter++) == void.
ASSERT_SAME_TYPE(decltype(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<InputView, Increment>>>()++),
std::declval<std::ranges::iterator_t<std::ranges::transform_view<InputView, PlusOne>>>()++),
void);
assert((iter += 4).base() == globalBuff + 4);

View File

@ -24,7 +24,7 @@ concept BaseInvocable = requires(std::ranges::iterator_t<std::ranges::transform_
constexpr bool test() {
{
std::ranges::transform_view<ContiguousView, Increment> transformView;
std::ranges::transform_view<ContiguousView, PlusOneMutable> transformView;
auto iter = std::move(transformView).begin();
ASSERT_SAME_TYPE(int*, decltype(iter.base()));
assert(iter.base() == globalBuff);
@ -33,13 +33,13 @@ constexpr bool test() {
}
{
std::ranges::transform_view<InputView, Increment> transformView;
std::ranges::transform_view<InputView, PlusOneMutable> transformView;
auto iter = transformView.begin();
assert(std::move(iter).base() == globalBuff);
ASSERT_SAME_TYPE(cpp20_input_iterator<int *>, decltype(std::move(iter).base()));
}
static_assert(!BaseInvocable<InputView, Increment>);
static_assert(!BaseInvocable<InputView, PlusOneMutable>);
return true;
}

View File

@ -20,9 +20,9 @@
constexpr bool test() {
{
std::ranges::transform_view<ContiguousView, Increment> transformView1;
std::ranges::transform_view<ContiguousView, PlusOne> transformView1;
auto iter1 = std::move(transformView1).begin();
std::ranges::transform_view<ContiguousView, Increment> transformView2;
std::ranges::transform_view<ContiguousView, PlusOne> transformView2;
auto iter2 = std::move(transformView2).begin();
assert(iter1 == iter2);
assert(iter1 + 1 != iter2);
@ -39,9 +39,9 @@ constexpr bool test() {
// TODO: when three_way_comparable is implemented and std::is_eq is implemented,
// uncomment this.
// {
// std::ranges::transform_view<ThreeWayCompView, Increment> transformView1;
// std::ranges::transform_view<ThreeWayCompView, PlusOne> transformView1;
// auto iter1 = transformView1.begin();
// std::ranges::transform_view<ThreeWayCompView, Increment> transformView2;
// std::ranges::transform_view<ThreeWayCompView, PlusOne> transformView2;
// auto iter2 = transformView2.begin();
//
// assert(std::is_eq(iter1 <=> iter2));
@ -52,8 +52,8 @@ constexpr bool test() {
// assert(std::is_gt(iter2 <=> iter1));
// assert(std::is_gteq(iter2 <=> iter1));
//
// static_assert( std::three_way_comparable<std::iterator_t<std::ranges::transform_view<ThreeWayCompView, Increment>>>);
// static_assert(!std::three_way_comparable<std::iterator_t<std::ranges::transform_view<ContiguousView, Increment>>>);
// static_assert( std::three_way_comparable<std::iterator_t<std::ranges::transform_view<ThreeWayCompView, PlusOne>>>);
// static_assert(!std::three_way_comparable<std::iterator_t<std::ranges::transform_view<ContiguousView, PlusOne>>>);
// }
return true;

View File

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

View File

@ -18,27 +18,46 @@
#include "../types.h"
int main(int, char**) {
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
{
std::ranges::transform_view transformView(ContiguousView{buff}, Increment{});
int buff[] = {0, 1, 2, 3, 4, 5, 6, 7};
using View = std::ranges::transform_view<ContiguousView, PlusOne>;
View transformView(ContiguousView{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{});
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{});
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{});
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{});
assert(*transformView.begin() == 1);
static_assert(!noexcept(*std::declval<std::ranges::iterator_t<View>>()));
ASSERT_SAME_TYPE(int&&, decltype(*std::declval<View>().begin()));
}
static_assert(!noexcept(
*std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, Increment>>>()));
static_assert( noexcept(
*std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, IncrementNoexcept>>>()));
ASSERT_SAME_TYPE(
int,
decltype(*std::declval<std::ranges::transform_view<RandomAccessView, Increment>>().begin()));
ASSERT_SAME_TYPE(
int&,
decltype(*std::declval<std::ranges::transform_view<RandomAccessView, IncrementRef>>().begin()));
ASSERT_SAME_TYPE(
int&&,
decltype(*std::declval<std::ranges::transform_view<RandomAccessView, IncrementRvalueRef>>().begin()));
return 0;
}

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}, Increment{});
std::ranges::transform_view transformView(ContiguousView{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, IncrementNoexcept>>&>())));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneNoexcept>>&>())));
static_assert(!noexcept(std::ranges::iter_move(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, Increment>>&>())));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneMutable>>&>())));
}
return true;

View File

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

View File

@ -17,8 +17,8 @@
#include "test_macros.h"
#include "../types.h"
static_assert(std::ranges::bidirectional_range<std::ranges::transform_view<BidirectionalView, IncrementConst>>);
static_assert(!std::ranges::bidirectional_range<std::ranges::transform_view<ForwardView, IncrementConst>>);
static_assert(std::ranges::bidirectional_range<std::ranges::transform_view<BidirectionalView, PlusOne>>);
static_assert(!std::ranges::bidirectional_range<std::ranges::transform_view<ForwardView, PlusOne>>);
static_assert(std::ranges::random_access_range<std::ranges::transform_view<RandomAccessView, IncrementConst>>);
static_assert(!std::ranges::random_access_range<std::ranges::transform_view<BidirectionalView, IncrementConst>>);
static_assert(std::ranges::random_access_range<std::ranges::transform_view<RandomAccessView, PlusOne>>);
static_assert(!std::ranges::random_access_range<std::ranges::transform_view<BidirectionalView, PlusOne>>);

View File

@ -21,18 +21,18 @@ template<class T>
concept EndIsIter = requires(T t) { ++t.end(); };
constexpr bool test() {
std::ranges::transform_view<SizedSentinelView, IncrementConst> transformView1;
std::ranges::transform_view<SizedSentinelView, PlusOne> transformView1;
// Going to const and back.
auto sent1 = transformView1.end();
std::ranges::sentinel_t<const std::ranges::transform_view<SizedSentinelView, IncrementConst>> sent2{sent1};
std::ranges::sentinel_t<const std::ranges::transform_view<SizedSentinelView, IncrementConst>> sent3{sent2};
std::ranges::sentinel_t<const std::ranges::transform_view<SizedSentinelView, PlusOne>> sent2{sent1};
std::ranges::sentinel_t<const std::ranges::transform_view<SizedSentinelView, PlusOne>> sent3{sent2};
(void)sent3;
static_assert(!EndIsIter<decltype(sent1)>);
static_assert(!EndIsIter<decltype(sent2)>);
assert(sent1.base() == globalBuff + 8);
std::ranges::transform_view transformView2(SizedSentinelView{4}, IncrementConst());
std::ranges::transform_view transformView2(SizedSentinelView{4}, PlusOne());
auto sent4 = transformView2.end();
auto iter = transformView1.begin();
{

View File

@ -19,22 +19,22 @@
constexpr bool test() {
int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
std::ranges::transform_view transformView1(ContiguousView{buff}, Increment{});
std::ranges::transform_view transformView1(ContiguousView{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, Increment>>>()[0]));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneMutable>>>()[0]));
static_assert( noexcept(
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, IncrementNoexcept>>>()[0]));
std::declval<std::ranges::iterator_t<std::ranges::transform_view<ContiguousView, PlusOneNoexcept>>>()[0]));
ASSERT_SAME_TYPE(
int,
decltype(std::declval<std::ranges::transform_view<RandomAccessView, Increment>>().begin()[0]));
decltype(std::declval<std::ranges::transform_view<RandomAccessView, PlusOneMutable>>().begin()[0]));
ASSERT_SAME_TYPE(
int&,
decltype(std::declval<std::ranges::transform_view<RandomAccessView, IncrementRef>>().begin()[0]));
decltype(std::declval<std::ranges::transform_view<RandomAccessView, Increment>>().begin()[0]));
ASSERT_SAME_TYPE(
int&&,
decltype(std::declval<std::ranges::transform_view<RandomAccessView, IncrementRvalueRef>>().begin()[0]));

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, IncrementRef>;
using TView = std::ranges::transform_view<ContiguousView, 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>);
@ -38,7 +38,7 @@ constexpr bool test() {
}
{
// Member typedefs for random access iterator.
using TView = std::ranges::transform_view<RandomAccessView, IncrementRef>;
using TView = std::ranges::transform_view<RandomAccessView, 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>);
@ -47,7 +47,7 @@ constexpr bool test() {
}
{
// Member typedefs for random access iterator/not-lvalue-ref.
using TView = std::ranges::transform_view<RandomAccessView, Increment>;
using TView = std::ranges::transform_view<RandomAccessView, PlusOneMutable>;
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::input_iterator_tag>); // Note: this is now input_iterator_tag.
@ -56,7 +56,7 @@ constexpr bool test() {
}
{
// Member typedefs for bidirectional iterator.
using TView = std::ranges::transform_view<BidirectionalView, IncrementRef>;
using TView = std::ranges::transform_view<BidirectionalView, Increment>;
using TIter = std::ranges::iterator_t<TView>;
static_assert(std::same_as<typename TIter::iterator_concept, std::bidirectional_iterator_tag>);
static_assert(std::same_as<typename TIter::iterator_category, std::bidirectional_iterator_tag>);
@ -65,7 +65,7 @@ constexpr bool test() {
}
{
// Member typedefs for forward iterator.
using TView = std::ranges::transform_view<ForwardView, IncrementRef>;
using TView = std::ranges::transform_view<ForwardView, Increment>;
using TIter = std::ranges::iterator_t<TView>;
static_assert(std::same_as<typename TIter::iterator_concept, std::forward_iterator_tag>);
static_assert(std::same_as<typename TIter::iterator_category, std::forward_iterator_tag>);
@ -74,10 +74,10 @@ constexpr bool test() {
}
{
// Member typedefs for input iterator.
using TView = std::ranges::transform_view<InputView, IncrementRef>;
using TView = std::ranges::transform_view<InputView, Increment>;
using TIter = std::ranges::iterator_t<TView>;
static_assert(std::same_as<typename TIter::iterator_concept, std::input_iterator_tag>);
static_assert(!HasIterCategory<InputView, IncrementRef>);
static_assert(!HasIterCategory<InputView, Increment>);
static_assert(std::same_as<typename TIter::value_type, int>);
static_assert(std::same_as<typename TIter::difference_type, std::ptrdiff_t>);
}

View File

@ -23,19 +23,19 @@ concept SizeInvocable = requires(T t) { t.size(); };
constexpr bool test() {
{
std::ranges::transform_view transformView(ContiguousView{}, Increment{});
std::ranges::transform_view transformView(ContiguousView{}, PlusOne{});
assert(transformView.size() == 8);
}
{
const std::ranges::transform_view transformView(ContiguousView{globalBuff, 4}, Increment{});
const std::ranges::transform_view transformView(ContiguousView{globalBuff, 4}, PlusOne{});
assert(transformView.size() == 4);
}
static_assert(!SizeInvocable<std::ranges::transform_view<ForwardView, Increment>>);
static_assert(!SizeInvocable<std::ranges::transform_view<ForwardView, PlusOne>>);
static_assert(SizeInvocable<std::ranges::transform_view<SizedSentinelNotConstView, Increment>>);
static_assert(!SizeInvocable<const std::ranges::transform_view<SizedSentinelNotConstView, Increment>>);
static_assert(SizeInvocable<std::ranges::transform_view<SizedSentinelNotConstView, PlusOne>>);
static_assert(!SizeInvocable<const std::ranges::transform_view<SizedSentinelNotConstView, PlusOne>>);
return true;
}

View File

@ -129,15 +129,15 @@ struct ThreeWayCompView : std::ranges::view_base {
constexpr ThreeWayCompIter end() const { return ThreeWayCompIter(globalBuff + 8); }
};
struct Increment {
struct PlusOneMutable {
constexpr int operator()(int x) { return x + 1; }
};
struct IncrementConst {
struct PlusOne {
constexpr int operator()(int x) const { return x + 1; }
};
struct IncrementRef {
struct Increment {
constexpr int& operator()(int& x) { return ++x; }
};
@ -145,7 +145,7 @@ struct IncrementRvalueRef {
constexpr int&& operator()(int& x) { return std::move(++x); }
};
struct IncrementNoexcept {
struct PlusOneNoexcept {
constexpr int operator()(int x) noexcept { return x + 1; }
};