Skip to content

Commit

Permalink
Implement LWG-3947 Unexpected constraints on `adjacent_transform_view…
Browse files Browse the repository at this point in the history
…::base()` (#4195)
  • Loading branch information
frederick-vs-ja authored Nov 17, 2023
1 parent 06d2966 commit f0625ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -9614,7 +9614,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();
}

0 comments on commit f0625ca

Please sign in to comment.