0

I have code that looks like this:

template <int Rows>
struct A {
    std::array<int, Rows*Rows> array;


    template <int X, int Y>
    int at(int x, int y) const {
        return array[X*x + Y*y];
    }
};


template <int Dim>
struct B {
    void dosomething(A<Dim> value) {
        auto x = value.at<0, 0>(0, 0);
    }
};

The compiler (gcc 6.3 and clang 3.9) complain about the line

auto x = value.at<0, 0>(0, 0);

with error: expected unqualified-id before numeric constant

I guess I have some ambiguity here, but I can't figure out how to resolve it. Also it is important that A and B are templates otherwise the error doesn't show up.

Some help and hints about what the compiler is really complaining about and how it could be fixed would be great.

melpomene
  • 84,125
  • 8
  • 85
  • 148
Gene
  • 410
  • 5
  • 16

0 Answers0