Skip to content
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

Implement LWG-3947 Unexpected constraints on adjacent_transform_view::base() #4195

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -9691,7 +9691,7 @@ namespace ranges {
: _Func(in_place, _STD move(_Func_)), _Inner(_STD move(_Range_)) {}

_NODISCARD constexpr _Vw base() const& noexcept(noexcept(_Inner.base())) // strengthened
requires copy_constructible<_Inner_view>
requires copy_constructible<_Vw>
{
return _Inner.base();
}
Expand Down
18 changes: 18 additions & 0 deletions tests/std/tests/P2321R2_views_adjacent_transform/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <array>
#include <cassert>
#include <forward_list>
#include <functional>
#include <ranges>
#include <span>
#include <tuple>
Expand Down Expand Up @@ -968,6 +969,23 @@ int main() {
test_one<3>(span<const int>{}, to_float, span<float>{});
}

{ // LWG-3947 Unexpected constraints on adjacent_transform_view::base()
struct weird_span : span<int>, ranges::view_base {
weird_span() = default;
weird_span(const weird_span&) = default;
weird_span(weird_span&) = delete;

weird_span& operator=(const weird_span&) = default;
};
STATIC_ASSERT(!copy_constructible<weird_span>);

using weird_adjacent_transform_view = ranges::adjacent_transform_view<weird_span, ranges::equal_to, 2>;
STATIC_ASSERT(!CanMemberBase<weird_adjacent_transform_view&>);
STATIC_ASSERT(!CanMemberBase<const weird_adjacent_transform_view&>);
STATIC_ASSERT(!CanMemberBase<const weird_adjacent_transform_view>);
STATIC_ASSERT(CanMemberBase<weird_adjacent_transform_view>);
}

STATIC_ASSERT((instantiation_test(), true));
instantiation_test();
}