[libcxx-commits] [PATCH] D115312: [libc++] [ranges] Simplify and fix a bug in ranges::empty.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 8 07:18:57 PST 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__ranges/empty.h:61
   };
 }
 
----------------
>>! @ldionne wrote:
> I don't especially like the fact that we're moving away from requires clauses and back to straight SFINAE. Can you check what effect this has on diagnostics?

Old: 32 lines; new: 8 lines. I would call the new version "frustratingly opaque" but the old version "annoyingly verbose."
https://godbolt.org/z/GseTh84jx
I can't think of any way to improve this. I thought of constraining `operator()` on `requires range<decay_t<_Tp>>`, but (1) `ranges::empty(e)` //doesn't// require `e` to satisfy `range` (if it provides `.empty()`), and (2) that doesn't help because SFINAE kicks in prior to constraint checking, and (3) the constraint doesn't help the user anyway because the failure case 99% of the time will be that `e` //is// a range but can't be checked for emptiness for some other obscure reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115312



More information about the libcxx-commits mailing list