[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
Thu Jul 28 00:47:12 PDT 2022


nikic added a comment.

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.

I'm not sure if C++ provides any good way to avoid that, short of explicitly marking certain constructors as deleted?

I'm wondering if it might not be better to make this a fully generic overload that accepts any range (i.e., anything with begin() and end()). Paradoxically, this will likely be less permissive in practice than having explicit iterator_range and ArrayRef overloads, because it allows less implicit conversions.


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