Skip to content

Commit 3a3a4c4

Browse files
mconcasdavidrohr
authored andcommitted
Use functor to check if we trick Clang13
1 parent 3a9df5e commit 3a3a4c4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Common/MathUtils/include/MathUtils/SMatrixGPU.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ struct meta_matrix_dot<0> {
259259

260260
namespace row_offsets_utils
261261
{
262+
template <unsigned int D>
263+
struct proxy_offset {
264+
static constexpr int off0(int i) { return i == 0 ? 0 : off0(i - 1) + i; }
265+
static constexpr int off2(int i, int j) { return j < i ? off0(i) + j : off0(j) + i; }
266+
static constexpr int off1(int i) { return off2(i / D, i % D); }
267+
int operator()(int i) const { return off1(i); }
268+
};
269+
262270
template <int...>
263271
struct indices {
264272
};
@@ -352,13 +360,10 @@ class MatRepSymGPU
352360
kSize = D * (D + 1) / 2 // rows*columns
353361
};
354362

355-
static constexpr int off0(int i) { return i == 0 ? 0 : off0(i - 1) + i; }
356-
static constexpr int off2(int i, int j) { return j < i ? off0(i) + j : off0(j) + i; }
357-
static constexpr int off1(int i) { return off2(i / D, i % D); }
358-
359363
static GPUdi() int off(int i)
360364
{
361-
static constexpr auto v = row_offsets_utils::make<D * D>(off1);
365+
row_offsets_utils::proxy_offset<D> proxy;
366+
static constexpr auto v = row_offsets_utils::make<D * D>(proxy);
362367
return v[i];
363368
}
364369

0 commit comments

Comments
 (0)