[PATCH] D130268: [NFC] Add SmallVector constructor to allow creation of SmallVector<T> from ArrayRef of items convertible to type T

Nikita Popov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 29 02:06:32 PDT 2022


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM

In D130268#3686811 <https://reviews.llvm.org/D130268#3686811>, @yurai007 wrote:

> In D130268#3684244 <https://reviews.llvm.org/D130268#3684244>, @nikic wrote:
>
>> I think my only concern with this change is that it will also allow some implicit ArrayRef constructors. For example, this will permit creating a SmallVector from `std::array`, `std::vector`, or just `T` -- but only if `ArrayRef` is in scope. This seems somewhat dangerous.
>
> Maybe I'm missing something, but is it right? It appears that only one implicit conversion in constructor is allowed: https://stackoverflow.com/questions/63320366/double-implicit-conversion-in-c
> I think going from vector/array to SmallVector is ill-formed unless we explicitly create temporary ArrayRef in-between: https://godbolt.org/z/Geqbajf1x

You're right... Everything's good then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130268



More information about the cfe-commits mailing list