[libcxx-commits] [PATCH] D101193: [libcxx][ranges] Add ranges::empty CPO.

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 29 14:16:27 PDT 2021


ldionne added inline comments.


================
Comment at: libcxx/include/__ranges/empty.h:38
+  template<class _Tp>
+  concept __can_invoke_size = requires(_Tp&& __t) { ranges::size(__t); };
+
----------------
tcanens wrote:
> I'd expect this one and the next to require `!__member_empty`?
I think the expression we check should be `ranges::size(_VSTD::forward<_Tp>(__t)) == 0` instead, according to the spec.

I'm actually not sure why the spec mandates checking `== 0` since `ranges::size(E)` is always supposed to be integer-like, but oh well.


================
Comment at: libcxx/include/__ranges/empty.h:70
+inline namespace __cpo {
+  inline constexpr const auto empty = __empty::__fn{};
+} // namespace __cpo
----------------
Do we need `const` here? Shouldn't `constexpr` imply `const` for objects? I thought I didn't see it on the other CPOs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101193



More information about the libcxx-commits mailing list