[libc-commits] [PATCH] D73530: [libc] Add a library of standalone C++ utilities.
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Jan 28 01:47:11 PST 2020
abrachet added inline comments.
================
Comment at: libc/utils/CPP/Array.h:23-29
+ Array() = default;
+
+ Array(const T (&Arr)[N]) {
+ for (size_t i = 0; i < N; ++i) {
+ Data[i] = Arr[i];
+ }
+ }
----------------
I know you aren't looking for comments, but just a quick one. std::array has no private members or constructors which makes it an aggregate, which gives it the super nice constexpr brace initializer syntax. This constructor would anyway need a reference to a preexisting array and couldn't be initialized like `Array<...> a({1, 2, 3, 4});` If you make `Data` public (and remove `Length` because we can just use `N`) and remove these 2 constructors then it can be initialized like `Array<int, 5> arr {1, 2, 3, 4, 5};`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73530/new/
https://reviews.llvm.org/D73530
More information about the libc-commits
mailing list