[libcxx-commits] [PATCH] D101079: [libcxx][ranges] Add ranges::size CPO.
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 22 15:59:35 PDT 2021
zoecarver added inline comments.
================
Comment at: libcxx/test/std/ranges/range.access/range.prim/size.compile.pass.cpp:126
+struct SizeMemberDisabled {
+ constexpr size_t size() { return 42; }
+};
----------------
Quuxplusone wrote:
> (A) Remove `constexpr`. Remove the function body. `size_t size() const;` is sufficient.
> (B) I notice you didn't const-qualify this member; I assume it was unintentional; but this is a good place to ask, what //is// supposed to happen if a type has a non-const-qualified `size()`? What does that imply for the truthiness of `sized_range<{const,} T{&,&&,}>`?
> (B) I notice you didn't const-qualify this member; I assume it was unintentional; but this is a good place to ask, what is supposed to happen if a type has a non-const-qualified size()? What does that imply for the truthiness of sized_range<{const,} T{&,&&,}>?
`sized_range<const T>` is true when `T` has a const member. It's false if the `size` member isn't const. That's why I actually wanted to keep this as simple as possible. It's //exactly// the same as `SizeMember` except it's disabled. I can add another one to test with a const member.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101079/new/
https://reviews.llvm.org/D101079
More information about the libcxx-commits
mailing list