Skip to content

Commit

Permalink
Even rvalue empty_views are borrowed_ranges (#2576)
Browse files Browse the repository at this point in the history
....which we somehow missed when implementing P1870R1 "`forwarding-range<T>` is too subtle".
  • Loading branch information
CaseyCarter authored Mar 19, 2022
1 parent b973fd0 commit 291e0ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ namespace ranges {
}
};

template <class _Ty>
inline constexpr bool enable_borrowed_range<empty_view<_Ty>> = true;

namespace views {
template <class _Ty>
inline constexpr empty_view<_Ty> empty;
Expand Down
1 change: 1 addition & 0 deletions tests/std/tests/P0896R4_views_empty/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ constexpr bool test_one_type() {
// validate type properties
using R = ranges::empty_view<T>;
static_assert(ranges::view<R> && ranges::contiguous_range<R> && ranges::sized_range<R> && ranges::common_range<R>);
static_assert(ranges::borrowed_range<R>);
static_assert(same_as<const R, decltype(views::empty<T>)>);
auto& r = views::empty<T>;

Expand Down

0 comments on commit 291e0ad

Please sign in to comment.