[PATCH] D145390: [ADT] Introduce `map_to_vector` helper
Laszlo Kindrat via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 9 06:02:27 PDT 2023
laszlokindrat added inline comments.
================
Comment at: llvm/include/llvm/ADT/SmallVectorExtras.h:23-24
+/// Map a range to a SmallVector with element types deduced from the mapping.
+template <class ContainerTy, class FuncTy>
+auto map_to_vector(ContainerTy &&C, FuncTy &&F) {
+ return to_vector(
----------------
kuhar wrote:
> I'd expect this to optionally accept small size, just like `to_vector<N>(...)` does. Is there a specific reason why only the default size is allowed?
>
> Also, do you plan on adding `map_to_vector_of`? IIRC `to_vector_of` was required for some common mlir functions like `DenseElementAttribute::getValues<T>()`
> I'd expect this to optionally accept small size, just like `to_vector<N>(...)` does. Is there a specific reason why only the default size is allowed?
No reason other than I prefer to add complexity incrementally. But I agree that this would be nice, so I will add it in a subsequent patch.
> Also, do you plan on adding `map_to_vector_of`?
I can't really find any use cases for this in the llvm monorepo. Do you have a downstream project that could benefit from it? I usually like to add this kind of sugar if/when there are lots of places that can benefit from it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145390/new/
https://reviews.llvm.org/D145390
More information about the llvm-commits
mailing list