[libc-commits] [PATCH] D100732: [libc] Enhance ArrayRef + unittests

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Sun Apr 18 12:58:30 PDT 2021

gchatelet created this revision.
gchatelet added a reviewer: sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added a project: libc-project.
gchatelet requested review of this revision.

This patch mostly adds unittests for `ArrayRef` and `MutableArrayRef`, additionnaly:

- We mimic the behavior of `std::vector` and disallow CV qualified type (`ArrayRef<const X>` is not allowed). This is to make sure that the type traits are always valid (e.g. `value_type`, `pointer`, ...).
- In the previous implementation `ArrayRef` would define `value_type` as `const T` but this is not correct, it should be `T` for both `MutableArrayRef` and `ArrayRef`.
- We add the `equals` method to ease testing,
- We define the constructor taking an `Array` outside of the base implementation to ensure we match `const Array<T>&` and not `Array<const T>&` in the case of `ArrayRef`.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100732.338392.patch
Type: text/x-patch
Size: 13090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210418/ba95b2d3/attachment.bin>

More information about the libc-commits mailing list