[libcxx-commits] [PATCH] D151629: [libc++][ranges] Implement P2494R2 (Relaxing range adaptors to allow for move only types)

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 21 17:27:04 PDT 2023


var-const requested changes to this revision.
var-const added a comment.
This revision now requires changes to proceed.

Almost LGTM. Please also rename `copyable_box.h` to `movable_box.h` and I think this patch should be good to go.



================
Comment at: libcxx/include/__ranges/copyable_box.h:41
 
+// Relaxing range adaptors to allow for move only types since C++23.
 template<class _Tp>
----------------
Nit: consider rephrasing this so that it's written from the perspective of the new state, not the previous state. That is, instead of saying "we allow this since C++23", consider saying "this wasn't allowed before C++23". Perhaps something like:
```
Note: until C++23, `__movable_box` was named `__copyable_box` and required the stored type to be copy-constructible, not just move-constructible; we preserve the old behavior in pre-C++23 modes.
```


================
Comment at: libcxx/test/std/ranges/range.adaptors/range.transform/general.pass.cpp:104
+    auto transformed = NonConstView(a, a + 4) | std::views::transform(MoveOnlyFunction());
+    int expected[4] = {43, 44, 45, 46};
+    assert(std::equal(transformed.begin(), transformed.end(), expected, expected + 4));
----------------
Nit: we usually rely on the compiler deducing the size of the array from the initializer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151629



More information about the libcxx-commits mailing list