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

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 30 10:08:42 PDT 2021


zoecarver added inline comments.


================
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;
+};
----------------
zoecarver wrote:
> cjdb wrote:
> > 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
> @cjdb I agree. It would be great if you could implement `__integer_like` as Louis described and then implement `__is_signed_integer_like` in terms of that. Once `__integer_like` exists I'll update this patch to use it. 
Ping: use `__integer_like` after rebasing. 


================
Comment at: libcxx/test/std/ranges/range.access/range.prim/size.pass.cpp:11
+// UNSUPPORTED: libcpp-no-concepts
+// UNSUPPORTED: gcc-10
+
----------------
Add msvc and clang. 


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