C ++模板无效的操作数类型'<unresolved overloaded =“”function =“”type =“”>'和...到二进制'运算符&lt;'</unresolved>

时间:2013-09-09 16:04:49

标签: c++ templates

所以我在调用模板类的模板成员函数时遇到了麻烦。当我尝试这样做时,我收到以下错误:

test.cpp:19:5: error: invalid operands of types ‘<unresolved
overloaded function type>’ and ‘unsigned int’ to binary ‘operator<’

和clang ++说:

test.cpp:19:5: error: reference to non-static member function must be called
    arrIn->partition<NPart>(NULL, NULL);
    ^~~~~~~~~~~~~~~~

任何想法如何解决这个问题?

谢谢!

#define NULL 0

template <class V, unsigned int N>
struct SubArray {
public:
  template <unsigned int NDIM>
  void partition(const int dimsToPart[], const unsigned int numParts[]) {
    // bla...
  }

};

template <unsigned int N>
struct CartTopology {
public:
  template <class V, unsigned int NArr, unsigned int NPart>
  void scatterArrayBlocked(SubArray<V, NArr> *arrIn, SubArray<V, NArr> *arrOut,
    const int dimsBefore[], const int dimsAfter[]) {
    arrIn->partition<NPart>(NULL, NULL);
  }

};

int main(int argc, char** argv) {
  SubArray<int, 2> arr;
  CartTopology<2> top;
  top.scatterArrayBlocked<int, 2, 2>(&arr, NULL, NULL, NULL);
  return 0;
}

0 个答案:

没有答案