[libcxx-commits] [PATCH] D102332: [libc++][nfc] remove duplicated __to_unsigned.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 12 11:32:05 PDT 2021

zoecarver added inline comments.

Comment at: libcxx/include/type_traits:2314-2318
+template <class _Tp>
+typename make_unsigned<_Tp>::type __to_unsigned(_Tp __x) noexcept {
+    return static_cast<typename make_unsigned<_Tp>::type>(__x);
Quuxplusone wrote:
> Mordante wrote:
> > cjdb wrote:
> > > Quuxplusone wrote:
> > > > Re naming: I approve of `__to_unsigned`. It simply converts to the `make_unsigned` version of the type, no more and no less.
> > > > @cjdb, if libc++ ever adds support for user-defined "unsigned-like but not unsigned" types, we can revisit the naming bikeshed (since we'll have to re-audit all the call-sites anyway, it'll actually be //good// to force the pull-requester to touch them all).
> > > If this were the case, then @ldionne wouldn't have asked for the concept `__integer_like`. At the very least, I think we should wait for Louis to chime in on this discussion.
> > I dislike the `_like` suffix. But it seems ranges uses this suffix a lot. So for that reason I think adding the `_like` suffix is a better idea. 
> I also dislike the `_like` suffix. "Ranges does it" is a great reason //not// to do it. :P So I'd like to see the shorter and less confusing (and less wishy-washy) name. But, I won't block this over it.
FWIW +1 to naming this `__to_unsigned` (no `_like`). But that can also be done after the fact. 

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list