Skip to content

Commit dd9c7cd

Browse files
Fixup
- missed `if constexpr` - wrong order and comparison
1 parent 51c1006 commit dd9c7cd

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

libcxx/include/__ranges/as_const_view.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct __fn : __range_adaptor_closure<__fn> {
160160
} else if constexpr (is_lvalue_reference_v<_Type> && constant_range<const _UType> && !view<_UType>) {
161161
return {__strategy::__const_is_constant_range,
162162
noexcept(ref_view(static_cast<const _UType&>(std::declval<_Type>())))};
163-
} else if (requires { as_const_view(std::declval<_Type>()); }) {
163+
} else if constexpr (requires { as_const_view(std::declval<_Type>()); }) {
164164
return {__strategy::__otherwise, noexcept(as_const_view(std::declval<_Type>()))};
165165
} else {
166166
return {__strategy::__none, false};

libcxx/test/std/iterators/const.iterators/iterator.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ constexpr void test_basic_operations() {
9393
static_assert(noexcept(iter_move(first)) == noexcept(std::ranges::iter_move(first.base())));
9494
static_assert(noexcept(std::ranges::iter_move(first)) == noexcept(std::ranges::iter_move(first.base())));
9595

96-
for (auto it = first; it != last; ++it) {
96+
for (auto it = first; it.base() != last.base(); ++it) {
9797
(void)*it;
9898
(void)it->x;
9999
(void)iter_move(it);
@@ -174,7 +174,7 @@ int main() {
174174
static_assert(std::is_constructible_v<ConstIt, It>);
175175
static_assert(std::is_convertible_v<It, ConstIt>);
176176
static_assert(std::is_constructible_v<ConstIt, const It&> == std::is_copy_constructible_v<It>);
177-
static_assert(std::is_constructible_v<const It&, ConstIt> == std::is_copy_constructible_v<It>);
177+
static_assert(std::is_convertible_v<const It&, ConstIt> == std::is_copy_constructible_v<It>);
178178
});
179179

180180
test_p2836r1();

libcxx/test/std/ranges/range.adaptors/range.as.const/ctor.pass.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ concept IsImplicitlyConstructible = requires(void (&fun)(T), Args&&... args) { f
4242
static_assert(IsImplicitlyConstructible<std::ranges::as_const_view<DefaultConstructibleView>>);
4343
static_assert(!IsImplicitlyConstructible<std::ranges::as_const_view<NonDefaultConstructibleView>, int>);
4444

45-
static_assert(std::is_constructible_v<std::ranges::as_const_view<DefaultConstructibleView>>, DefaultConstructibleView);
45+
static_assert(std::is_constructible_v<std::ranges::as_const_view<DefaultConstructibleView>, DefaultConstructibleView>);
46+
static_assert(
47+
std::is_constructible_v<std::ranges::as_const_view<DefaultConstructibleView>, NonDefaultConstructibleView>);
4648
static_assert(!std::is_convertible_v<DefaultConstructibleView, std::ranges::as_const_view<DefaultConstructibleView>>);
49+
static_assert(
50+
!std::is_convertible_v<DefaultConstructibleView, std::ranges::as_const_view<NonDefaultConstructibleView>>);
4751

4852
constexpr bool test() {
4953
std::ranges::as_const_view<DefaultConstructibleView> view = {};

0 commit comments

Comments
 (0)