Skip to content
Snippets Groups Projects

[cleanup]Simplify ISTLMatrixBackend entry access by multi-indices

Merged Carsten Gräser requested to merge feature/cleanup-istlmatrixbackend into master
1 file
+ 9
3
Compare changes
  • Side-by-side
  • Inline
  • b7682e10
    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.
@@ -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);
});
}
Loading