@@ -780,15 +780,17 @@ auto SparseElementsAttr::getValues() const
780
780
auto zeroValue = getZeroValue<T>();
781
781
auto valueIt = getValues ().getValues <T>().begin ();
782
782
const std::vector<ptrdiff_t > flatSparseIndices (getFlattenedSparseIndices ());
783
- // TODO: Move-capture flatSparseIndices when c++14 is available.
784
- std::function<T (ptrdiff_t )> mapFn = [=](ptrdiff_t index) {
785
- // Try to map the current index to one of the sparse indices.
786
- for (unsigned i = 0 , e = flatSparseIndices.size (); i != e; ++i)
787
- if (flatSparseIndices[i] == index)
788
- return *std::next (valueIt, i);
789
- // Otherwise, return the zero value.
790
- return zeroValue;
791
- };
783
+ std::function<T (ptrdiff_t )> mapFn =
784
+ [flatSparseIndices{std::move (flatSparseIndices)},
785
+ valueIt{std::move (valueIt)},
786
+ zeroValue{std::move (zeroValue)}](ptrdiff_t index) {
787
+ // Try to map the current index to one of the sparse indices.
788
+ for (unsigned i = 0 , e = flatSparseIndices.size (); i != e; ++i)
789
+ if (flatSparseIndices[i] == index)
790
+ return *std::next (valueIt, i);
791
+ // Otherwise, return the zero value.
792
+ return zeroValue;
793
+ };
792
794
return llvm::map_range (llvm::seq<ptrdiff_t >(0 , getNumElements ()), mapFn);
793
795
}
794
796
0 commit comments