[libcxx-commits] [PATCH] D80821: [libc++] Return nullptr from an empty array begin()

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 29 11:27:08 PDT 2020


zoecarver added a comment.

@ldionne I disagree. I think we can have all the things here :)

We're going to need four overloads in order to make this work (hopefully factored out into their own helper object):

1. `N != 0`: use the current implementation (or something equivalent).
2. `T` is trivially copyable *and* we're in a constexpr context: hold a `char` array and use bit_cast to convert it to `T*`.
3. `T` is trivially copyable and where *not* in a constexpr context: hold a `char` array and use `reinterpret_cast` (to eliminate an extra stack alloc).
4. `T` is not trivially copyable: use the union trick (currently implemented in master).

I'm happy to help implement this if you want (I know you've already put a lot of time into improving `std::array` so, I'm happy to help wherever I can).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80821





More information about the libcxx-commits mailing list