[libcxx-commits] [PATCH] D101079: [libcxx][ranges] Add ranges::size CPO.

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 23 11:33:17 PDT 2021


cjdb added a comment.

> Can we add conformance tests for the types defined in libc++? std::vector & friends.

This should be done in the `sized_range` patch IMO, similar to how I deferred conformance tests for D100255 <https://reviews.llvm.org/D100255> to D100269 <https://reviews.llvm.org/D100269>.



================
Comment at: libcxx/include/__ranges/size.h:58
+concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) {
+  { _VSTD::__decay_copy(_VSTD::forward<_Tp>(__t).size()) } -> integral;
+};
----------------
ldionne wrote:
> I think we need to introduce a proper concept for integer-like types:
> 
> 
> ```
> template <typename _Ip>
> concept __integer_like = !same_as<bool, _Ip> && integral<_Ip>;
> ```
> 
> According to the Standard:
> 
> > A type `I` other than `cv bool` is integer-like if it models `integral<I>` or if it is an integer-class type.
> 
> That would also be an indirection point where we can add our own implementation-defined integer-class type if we have one.
> 
> Right now, my understanding is that this concept would be satisfied if `t.size()` returned a `bool`. Instead, we should use `-> __integer_like` so that `bool` is excluded. Can you confirm that it's a problem and add a test that fails when that's the case?
> 
> This comment applies to other uses of `integral` below (and so we should add tests for those too).
Yes, but it looks like I can do this in D100080. Nice catch! http://eel.is/c++draft/iterators#iterator.concept.winc-11


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