Skip to content
Snippets Groups Projects
Commit 9630ef9c authored by Carsten Gräser's avatar Carsten Gräser
Browse files

Capture structured bindings by value

Capturing structured bindings by reference is not allowed
before C++20. Here we can instead capture by value as a work around,
because the shifted indices are thin wrappers.
parent 63427735
No related branches found
No related tags found
1 merge request!149[cleanup]Simplify ISTLMatrixBackend entry access by multi-indices
Pipeline #59731 passed
......@@ -86,7 +86,9 @@ namespace Impl {
{
assert(jjj.size()>0);
auto [j, jj] = splitIndex(jjj);
return visitMatrixEntry(matrix, _0, j, [&](auto&& matrix_0j) -> decltype(auto) {
// We have to capture jj explicitly by value, because capturing structured bindings
// by reference is not allowed before C++20
return visitMatrixEntry(matrix, _0, j, [&, jj=jj](auto&& matrix_0j) -> decltype(auto) {
return visitMatrixEntryRecursive(matrix_0j, iii, jj, f);
});
}
......@@ -94,7 +96,9 @@ namespace Impl {
{
assert(iii.size()>0);
auto [i, ii] = splitIndex(iii);
return visitMatrixEntry(matrix, i, _0, [&](auto&& matrix_i0) -> decltype(auto) {
// We have to capture ii explicitly by value, because capturing structured bindings
// by reference is not allowed before C++20
return visitMatrixEntry(matrix, i, _0, [&, ii=ii](auto&& matrix_i0) -> decltype(auto) {
return visitMatrixEntryRecursive(matrix_i0, ii, jjj, f);
});
}
......@@ -104,7 +108,9 @@ namespace Impl {
assert(jjj.size()>0);
auto [i, ii] = splitIndex(iii);
auto [j, jj] = splitIndex(jjj);
return visitMatrixEntry(matrix, i, j, [&](auto&& matrix_ij) -> decltype(auto) {
// We have to capture ii and jj explicitly by value, because capturing structured bindings
// by reference is not allowed before C++20
return visitMatrixEntry(matrix, i, j, [&, ii=ii, jj=jj](auto&& matrix_ij) -> decltype(auto) {
return visitMatrixEntryRecursive(matrix_ij, ii, jj, f);
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment