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

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 22 11:26:10 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__ranges/size.h:105
+
+  size_t operator()(auto &&) const = delete;
+};
----------------
zoecarver wrote:
> zoecarver wrote:
> > cjdb wrote:
> > > Quuxplusone wrote:
> > > > Could you explain why this `=delete`'d overload is necessary?
> > > > I see how it is //observable// ( https://godbolt.org/z/PGxzf4jGz ) and I assume it is //permitted//, but I don't see why it's //necessary// in libc++. Other implementors (GCC, MSVC) get away without it.
> > > It provides good intrinsic documentation. @zoecarver can you please contrast the diagnostic with/without this deletion, and maybe upload them to a GitHub gist?
> > This is a so called poison pill. I could be persuaded to remove it, but I think it makes the error message nicer for users. I'd like to point out that other implementations //do// use it. 
> @cjdb I didn't see your comments when I made mine :)
> 
> Anyway, here's a gist: https://gist.github.com/zoecarver/594015f42664e3daa7ab7c3978027682
> 
> I'm now less convinced that deleting this overload is the correct way to go. 
@zoecarver: No. The "poison pill" is the thing on lines 50-51. This is a plain old deleted overload of `operator()`, and GCC/MSVC seem not to use it. Check out the godbolt where the difference is observable:  https://godbolt.org/z/PGxzf4jGz and compare it locally versus your implementation.


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