[libcxx-commits] [PATCH] D118164: [libc++] [ranges] ref_view and empty_view are borrowed ranges. Normalize borrowed_range tests.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 25 13:19:30 PST 2022


Quuxplusone marked an inline comment as done.
Quuxplusone added a comment.

In D118164#3270391 <https://reviews.llvm.org/D118164#3270391>, @ldionne wrote:

> Instead of using `single_view` and `empty_view` to mean `NonBorrowedRange` and `BorrowedRange`, I would rather retain such "archetypes" in `test_range.h` and use them in our tests. That way, our tests won't be wrong if our implementation is, and their names is more telling than `single_view` and `empty_view`, which say nothing about their borrowable-ness. This would even be acceptable, but while we're at it why not define them self-standing:
>
>   using NonBorrowedRange = std::ranges::single_view;
>   using BorrowedRange = std::ranges::empty_view;

My resistance to this idea is the usual: "there's no such thing as an archetype." These tests do test the specific codepath devoted to borrowed ranges; but we shouldn't lose sight of the fact that the specific `T` we're instantiating them with has //all// the properties of `single_view<T>` or `empty_view<T>` — for example, it's a view itself, as opposed to a non-view. I actually just proposed a non-view `BorrowedRange` in one of @philnik's reviews! I suppose we could have our thing be named `BorrowedView`, and then have a `BorrowedRange` that's not a view, as well... Anyway, I'll pursue that a little bit, but at the moment I'm skeptical.
(Note that `take_view<BorrowedView>` is OK but `take_view<BorrowedRange /*i.e. not a view*/>` would be ill-formed.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118164/new/

https://reviews.llvm.org/D118164



More information about the libcxx-commits mailing list