Skip to content

Commit 731206f

Browse files
committed
[mlir] Move move capture in SparseElementsAttr::getValues
This was a TODO for the move to C++14. Now that the move has been completed, we can resolve it.
1 parent b49a798 commit 731206f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

mlir/include/mlir/IR/BuiltinAttributes.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -780,15 +780,17 @@ auto SparseElementsAttr::getValues() const
780780
auto zeroValue = getZeroValue<T>();
781781
auto valueIt = getValues().getValues<T>().begin();
782782
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+
};
792794
return llvm::map_range(llvm::seq<ptrdiff_t>(0, getNumElements()), mapFn);
793795
}
794796

0 commit comments

Comments
 (0)