Skip to content

[libc++] Add missing CPO tests for range adaptors #149557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 25, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <concepts>
#include <iterator>
#include <ranges>
#include <sstream>
#include <type_traits>
#include <utility>

Expand All @@ -26,7 +27,7 @@ constexpr bool test(CPO& o, Args&&...) {
static_assert(std::is_trivially_copyable_v<CPO>);
static_assert(std::is_trivially_default_constructible_v<CPO>);

auto p = o;
auto p = o;
using T = decltype(p);

// The type of a customization point object, ignoring cv-qualifiers, shall model semiregular.
Expand All @@ -43,7 +44,8 @@ constexpr bool test(CPO& o, Args&&...) {

int a[10];
int arrays[10][10];
//std::pair<int, int> pairs[10];
std::pair<int, int> pairs[10];
std::istringstream stream;

// [concept.swappable]
static_assert(test(std::ranges::swap, a, a));
Expand Down Expand Up @@ -77,23 +79,41 @@ static_assert(test(std::ranges::ssize, a));

// [range.factories]
// views::empty<T> is not a CPO
static_assert(test(std::views::iota, 1));
static_assert(test(std::views::iota, 1, 10));
//static_assert(test(std::views::istream<int>, 1);
static_assert(test(std::views::iota, 1));
static_assert(test(std::views::istream<int>, stream));
static_assert(test(std::views::repeat, 1));
static_assert(test(std::views::single, 4));

// [range.adaptors]
// static_assert(test(std::views::adjacent_transform<2>, [](int x, int y) { return x + y; }, a));
// static_assert(test(std::views::adjacent<2>, a));
static_assert(test(std::views::all, a));
// static_assert(test(std::views::as_const, a));
static_assert(test(std::views::as_rvalue, a));
// static_assert(test(std::views::cache_latest, a));
// static_assert(test(std::views::cartesian_product, a, a, a));
static_assert(test(std::views::chunk_by, a, [](int x, int y) { return x < y; }));
// static_assert(test(std::views::chunk, a, 1));
static_assert(test(std::views::common, a));
// static_assert(test(std::views::concat, a, a));
static_assert(test(std::views::counted, a, 10));
static_assert(test(std::views::drop_while, a, [](int x) { return x < 10; }));
static_assert(test(std::views::drop, a, 10));
//static_assert(test(std::views::drop_while, a, [](int x){ return x < 10; }));
//static_assert(test(std::views::elements<0>, pairs));
static_assert(test(std::views::filter, a, [](int x){ return x < 10; }));
static_assert(test(std::views::elements<0>, pairs));
// static_assert(test(std::views::enumerate, a));
static_assert(test(std::views::filter, a, [](int x) { return x < 10; }));
static_assert(test(std::views::join_with, 1));
static_assert(test(std::views::join, arrays));
//static_assert(test(std::views::split, a, 4));
static_assert(test(std::views::keys, pairs));
static_assert(test(std::views::lazy_split, a, 4));
static_assert(test(std::views::reverse, a));
static_assert(test(std::views::split, a, 4));
// static_assert(test(std::views::stride, a, 1));
static_assert(test(std::views::take_while, a, [](int x) { return x < 10; }));
static_assert(test(std::views::take, a, 10));
//static_assert(test(std::views::take_while, a, [](int x){ return x < 10; }));
static_assert(test(std::views::transform, a, [](int x){ return x + 1; }));
// static_assert(test(std::views::to_input, a));
static_assert(test(std::views::transform, a, [](int x) { return x + 1; }));
static_assert(test(std::views::values, pairs));
// static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a));
static_assert(test(std::views::zip, a, a));
Loading