Skip to content

Commit 5ca6002

Browse files
committed
[libc++][ranges] implement 'ranges::elements_of'
1 parent 03ccc54 commit 5ca6002

File tree

3 files changed

+1
-22
lines changed

3 files changed

+1
-22
lines changed

libcxx/include/__ranges/elements_of.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,9 @@ template <range _Range, class _Allocator = allocator<byte>>
3333
struct elements_of {
3434
_LIBCPP_NO_UNIQUE_ADDRESS _Range range;
3535
_LIBCPP_NO_UNIQUE_ADDRESS _Allocator allocator = _Allocator();
36-
37-
# if !defined(__cpp_aggregate_paren_init)
38-
// This explicit constructor is required because AppleClang 15 hasn't
39-
// implemented P0960R3.
40-
template <std::ranges::range _Range2, class _Allocator2 = std::allocator<byte>>
41-
_LIBCPP_HIDE_FROM_ABI explicit constexpr elements_of(_Range2&& __range, _Allocator2&& __alloc = _Allocator())
42-
: range(std::forward<_Range2>(__range)), allocator(std::forward<_Allocator2>(__alloc)) {}
43-
# endif
4436
};
4537

4638
template <class _Range, class _Allocator = allocator<byte>>
47-
# if defined(_LIBCPP_COMPILER_CLANG_BASED) && defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600
48-
// This explicit constraint is required because AppleClang 15 might not deduce
49-
// the correct type for `_Range` without it.
50-
requires range<_Range&&>
51-
# endif
5239
elements_of(_Range&&, _Allocator = _Allocator()) -> elements_of<_Range&&, _Allocator>;
5340

5441
} // namespace ranges

libcxx/test/std/ranges/range.utility/range.elementsof/ctad.compile.pass.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ constexpr bool test() {
4141
static_assert(std::same_as<decltype(std::ranges::elements_of(Range<Iterator>(), Allocator())),
4242
std::ranges::elements_of<Range<Iterator>&&, Allocator>>);
4343

44-
// AppleClang 15 hasn't implemented P0960R3 and P1816R0
45-
#if defined(__cpp_aggregate_paren_init) && __cpp_aggregate_paren_init >= 201902L && defined(__cpp_deduction_guides) && \
46-
__cpp_deduction_guides >= 201907L
4744
static_assert(std::same_as<decltype(std::ranges::elements_of{.range = r, .allocator = a}),
4845
std::ranges::elements_of<Range<Iterator>&, Allocator>>);
4946
static_assert(
5047
std::same_as<decltype(std::ranges::elements_of{.range = Range<Iterator>(), .allocator = Allocator()}),
5148
std::ranges::elements_of<Range<Iterator>&&, Allocator>>);
52-
#endif
5349
});
5450
});
5551

libcxx/test/std/ranges/range.utility/range.elementsof/elements_of.pass.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ constexpr bool test_range() {
4848
[[maybe_unused]] std::same_as<Allocator> decltype(auto) elements_of_allocator = elements_of.allocator;
4949
}
5050
{
51-
// designated initializer
52-
// AppleClang 15 hasn't implemented P0960R3 and P1816R0
53-
#if defined(__cpp_aggregate_paren_init) && __cpp_aggregate_paren_init >= 201902L && defined(__cpp_deduction_guides) && \
54-
__cpp_deduction_guides >= 201907L
51+
// designated initializer
5552
std::same_as<elements_of_t> decltype(auto) elements_of = std::ranges::elements_of{
5653
.range = r,
5754
.allocator = Allocator(),
@@ -61,7 +58,6 @@ constexpr bool test_range() {
6158
assert(std::ranges::distance(elements_of_range) == 4);
6259
}
6360
[[maybe_unused]] std::same_as<Allocator> decltype(auto) elements_of_allocator = elements_of.allocator;
64-
#endif
6561
}
6662
{
6763
// copy constructor

0 commit comments

Comments
 (0)