Skip to content

Commit

Permalink
P2321R2: views::adjacent_transform, views::pairwise_transform (#3546
Browse files Browse the repository at this point in the history
)

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
JMazurkiewicz and StephanTLavavej authored Mar 17, 2023
1 parent 8eb3a06 commit 56a65e0
Showing 8 changed files with 1,393 additions and 27 deletions.
394 changes: 390 additions & 4 deletions stl/inc/ranges

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
@@ -335,7 +335,6 @@
// P2291R3 constexpr Integral <charconv>
// P2302R4 ranges::contains, ranges::contains_subrange
// P2321R2 zip
// (missing views::adjacent_transform)
// P2322R6 ranges::fold_left, ranges::fold_right, Etc.
// P2387R3 Pipe Support For User-Defined Range Adaptors
// P2404R3 Move-Only Types For Comparison Concepts
@@ -1739,6 +1738,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
#define __cpp_lib_ranges_starts_ends_with 202106L
#define __cpp_lib_ranges_stride 202207L
#define __cpp_lib_ranges_to_container 202202L
#define __cpp_lib_ranges_zip 202110L
#endif // __cpp_lib_concepts

#define __cpp_lib_spanstream 202106L
4 changes: 0 additions & 4 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
@@ -311,10 +311,6 @@ std/utilities/format/format.tuple/parse.pass.cpp FAIL
std/utilities/format/format.tuple/set_brackets.pass.cpp FAIL
std/utilities/format/format.tuple/set_separator.pass.cpp FAIL

# P2321R2 zip
std/language.support/support.limits/support.limits.general/tuple.version.compile.pass.cpp FAIL
std/language.support/support.limits/support.limits.general/utility.version.compile.pass.cpp FAIL


# *** MISSING COMPILER FEATURES ***
# MSVC doesn't properly support [[no_unique_address]]
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
@@ -569,6 +569,7 @@ tests\P2302R4_ranges_alg_contains
tests\P2302R4_ranges_alg_contains_subrange
tests\P2321R2_proxy_reference
tests\P2321R2_views_adjacent
tests\P2321R2_views_adjacent_transform
tests\P2321R2_views_zip
tests\P2321R2_views_zip_transform
tests\P2322R6_ranges_alg_fold
28 changes: 10 additions & 18 deletions tests/std/tests/P2321R2_views_adjacent/test.cpp
Original file line number Diff line number Diff line change
@@ -142,19 +142,15 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {

// Check view_interface::empty and operator bool
STATIC_ASSERT(CanMemberEmpty<R>);
STATIC_ASSERT(CanBool<R> == CanEmpty<R>);
if constexpr (CanMemberEmpty<R>) {
assert(r.empty() == is_empty);
assert(static_cast<bool>(r) == !is_empty);
}
STATIC_ASSERT(CanBool<R>);
assert(r.empty() == is_empty);
assert(static_cast<bool>(r) == !is_empty);

// Check view_interface::empty and operator bool (const)
STATIC_ASSERT(CanMemberEmpty<const R>);
STATIC_ASSERT(CanBool<const R> == CanEmpty<const R>);
if constexpr (CanMemberEmpty<const R>) {
assert(as_const(r).empty() == is_empty);
assert(static_cast<bool>(as_const(r)) == !is_empty);
}
STATIC_ASSERT(CanBool<const R>);
assert(as_const(r).empty() == is_empty);
assert(static_cast<bool>(as_const(r)) == !is_empty);

// Check content
assert(ranges::equal(r, expected));
@@ -306,16 +302,12 @@ constexpr bool test_one(Rng&& rng, Expected&& expected) {
}

// Check view_interface::front
STATIC_ASSERT(CanMemberFront<R> == forward_range<V>);
if constexpr (CanMemberFront<R>) {
assert(r.front() == *begin(expected));
}
STATIC_ASSERT(CanMemberFront<R>);
assert(r.front() == *begin(expected));

// Check view_interface::front (const)
STATIC_ASSERT(CanMemberFront<const R> == forward_range<const V>);
if constexpr (CanMemberFront<const R>) {
assert(as_const(r).front() == *begin(expected));
}
STATIC_ASSERT(CanMemberFront<const R>);
assert(as_const(r).front() == *begin(expected));

// Check view_interface::back
STATIC_ASSERT(CanMemberBack<R> == (bidirectional_range<V> && common_range<V>) );
4 changes: 4 additions & 0 deletions tests/std/tests/P2321R2_views_adjacent_transform/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\strict_concepts_latest_matrix.lst
973 changes: 973 additions & 0 deletions tests/std/tests/P2321R2_views_adjacent_transform/test.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1762,6 +1762,20 @@ STATIC_ASSERT(__cpp_lib_ranges_to_container == 202202L);
#endif
#endif

#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
#ifndef __cpp_lib_ranges_zip
#error __cpp_lib_ranges_zip is not defined
#elif __cpp_lib_ranges_zip != 202110L
#error __cpp_lib_ranges_zip is not 202110L
#else
STATIC_ASSERT(__cpp_lib_ranges_zip == 202110L);
#endif
#else
#ifdef __cpp_lib_ranges_zip
#error __cpp_lib_ranges_zip is defined
#endif
#endif

#if _HAS_CXX17
#ifndef __cpp_lib_raw_memory_algorithms
#error __cpp_lib_raw_memory_algorithms is not defined

0 comments on commit 56a65e0

Please sign in to comment.