1

I've compiled the code below on different compilers without any problem, but when upgrading to GCC 8 I got the error:

error: invalid operands of types ‘<unresolved overloaded function type>’ and ‘int’ to binary ‘operator<’ left->takeBlock<0, 0, 0, 0, M, N0>(*this);

Why is this happening?

typedef int index_t;

template<int M, int N = M, typename T = double>
struct mat {

public:
    template<index_t I, index_t J, index_t Isrc, index_t Jsrc, index_t Mblock, index_t Nblock, index_t Msrc, index_t Nsrc> // I, J, Isrc, Jsrc, Mblock, Nblock must be explicitly specified.
    void takeBlock(const mat<Msrc, Nsrc, T>& src) {
    }
    template<index_t N0>
    void split(mat<M, N0, T>* left, mat<M, N - N0, T>* right) const {
        static_assert(N0 < N, "N0 >= N");
        left->takeBlock<0, 0, 0, 0, M, N0>(*this);  // <------------- *** ERROR ON THIS LINE ***
        right->takeBlock<0, 0, 0, N0, M, N - N0>(*this);
    }


};

int main(int argc, char **argv)
{
    mat<3,1> translation;
    mat<3, 4> transformation;
    mat<3> R;
    transformation.split(&R, &translation);

    return 0;
}

Edit:

It seems I can fix it by replacing ->takeBlock< with ->template takeBlock<

Museful
  • 6,711
  • 5
  • 42
  • 68

0 Answers0