[libcxx-commits] [PATCH] D106708: [libc++] Add range_size_t

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 24 05:15:26 PDT 2021


Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.

LGTM, modulo comment.



================
Comment at: libcxx/test/std/ranges/range.req/range.range/range_size_t.compile.pass.cpp:28
+
+static_assert(std::same_as<std::ranges::range_size_t<Range>, short>);
----------------
Quuxplusone wrote:
> Please add SFINAE-friendliness tests. I recommend replacing this whole file with:
> ```
> template<class T>
> concept has_size_t = requires { typename std::ranges::range_size_t<T>; };
> 
> struct A { int *begin(); int *end(); short size(); };
> static_assert(std::same_as<std::ranges::range_size_t<A>, short>);
> static_assert(std::same_as<std::ranges::range_size_t<A&>, short>);
> static_assert(std::same_as<std::ranges::range_size_t<A&&>, short>);
> static_assert(!has_size_t<const A>);
> static_assert(!has_size_t<const A&>);
> static_assert(!has_size_t<const A&&>);
> 
> struct B { int *begin(); int *end(); };
> static_assert(std::same_as<std::ranges::range_size_t<B>, std::size_t>);
> static_assert(std::same_as<std::ranges::range_size_t<B&>, std::size_t>);
> static_assert(std::same_as<std::ranges::range_size_t<B&&>, std::size_t>);
> static_assert(!has_size_t<const B>);
> static_assert(!has_size_t<const B&>);
> static_assert(!has_size_t<const B&&>);
> 
> struct C { bidirectional_iterator<int*> begin(); bidirectional_iterator<int*> end(); };
> static_assert(!has_size_t<C>);
> ```
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106708



More information about the libcxx-commits mailing list