[libcxx-commits] [PATCH] D114761: [libc++][ranges] Implement [special.mem.concepts].

Joe Loser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 2 09:07:53 PST 2021


jloser added inline comments.


================
Comment at: libcxx/test/std/algorithms/specialized.algorithms/special.mem.concepts/special.mem.concepts.compile.pass.cpp:49-52
+// __nothrow_sentinel_for
+
+static_assert(std::ranges::__nothrow_sentinel_for<int*, int*>);
+static_assert(!std::ranges::__nothrow_sentinel_for<int*, long*>);
----------------
var-const wrote:
> Quuxplusone wrote:
> > For this one, I think it would be reasonable to test that `__nothrow_sentinel_for` subsumes `sentinel_for`, //and// vice versa. However, that might also be overkill. Untested code:
> > ```
> > bool ntsf_subsumes_sf(__nothrow_sentinel_for<char*> auto) requires true { return true; }
> > bool ntsf_subsumes_sf(sentinel_for<char*> auto);
> > 
> > bool sf_subsumes_ntsf(sentinel_for<char*> auto) requires true { return true; }
> > bool sf_subsumes_ntsf(__nothrow_sentinel_for<char*> auto);
> > 
> > assert(ntsf_subsumes_sf("foo"));
> > assert(sf_subsumes_ntsf("foo"));
> > ```
> Honestly, it seems to me like it's a little overkill. The Standard specifies `nothrow-sentinel-for` to be essentially an alias for `sentinel_for`, and it doesn't really make sense to implement it any other way.
I like the general idea of testing subsumption for concepts, including these. Overkill for most user concepts in codebases, but for standard library implementors, I think it's reasonable. WDYT, @ldionne @cjdb?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114761



More information about the libcxx-commits mailing list