没有已知从T ** [2]到T *(*)[2]

时间:2017-02-26 19:59:06

标签: c++

我在一个现有的C ++ 11项目上工作,我在创建一个问题时遇到了问题 指针数组。不幸的是,错误并没有在最小的情况下持续存在 示例

我要调用的模板化类的成员函数需要两乘二 FullCloverBlock指针数组,如下所示:

void two_flav_achimbdpsi(FourSpinorBlock *res[2],
                         const FourSpinorBlock *chi[2],
                         const FourSpinorBlock *psi[2],
                         const SU3MatrixBlock *u,
                         FullCloverBlock *clov[2][2],
                         const double beta,
                         const double epsilon,
                         const int isign,
                         const int cb);

在此函数的测试中,声明了一堆字段以供所有字段使用 测试:

FullClover *A_cb0_plus = (FullClover *)geom.allocCBFullClov();
FullClover *A_cb0_minus = (FullClover *)geom.allocCBFullClov();
FullClover *A_cb1_plus = (FullClover *)geom.allocCBFullClov();
FullClover *A_cb1_minus = (FullClover *)geom.allocCBFullClov();

FullClover *clov_packed[2][2];

clov_packed[0][0] = A_cb0_plus;
clov_packed[0][1] = A_cb0_minus;
clov_packed[1][0] = A_cb1_plus;
clov_packed[1][1] = A_cb1_minus;

类型FullCloverFullCloverBlock是相同的,只有 不同文件中的typedef个不同。

然后在该函数中我构建了一个容器来保存数量 利益。我想两次使用相同的东西,这是需要的 应用

FullClover **two_flav_clov[2] = {clov_packed[target_cb],
                                 clov_packed[target_cb]};

然后我尝试使用该新变量调用该函数:

tmdslash.two_flav_achimbdpsi(two_flav_res,
                             two_flav_chi,
                             two_flav_psi,
                             u_packed[target_cb],
                             two_flav_clov,
                             beta,
                             epsilon,
                             isign,
                             target_cb);

我希望two_flav_clov的类型为FullClover ***或 当量。这应该与函数中所需的类型匹配 我想打电话给two_flav_achimbdpsi。但是,我收到以下错误:

tests/testNDTMvsTMCloverFull.cc: In instantiation of 'void testNDTMvsTMCloverFull::runTest() [with FT = float; int V = 8; int S = 4; bool compress = true; U = QDP::OLattice<QDP::PScalar<QDP::PColorMatrix<QDP::RComplex<float>, 3> > >; Phi = QDP::OLattice<QDP::PSpinVector<QDP::PColorVector<QDP::RComplex<float>, 3>, 4> >]':
tests/testNDTMvsTMCloverFull.cc:838:58:   required from here
tests/testNDTMvsTMCloverFull.cc:421:17: error: no matching function for call to 'QPhiX::TMClovDslash<float, 8, 4, true>::two_flav_achimbdpsi(float (* [2])[3][4][2][4], float (* [2])[3][4][2][4], float (* [2])[3][4][2][4], float (*&)[8][2][3][2][8], FullClover** [2], double&, const double&, int&, int&)'
                 tmdslash.two_flav_achimbdpsi(two_flav_res,
                 ^~~~~~~~
In file included from include/qphix/tm_clov_dslash_def.h:376:0,
                 from include/qphix/qdp_packer_parscalar.h:21,
                 from include/qphix/qdp_packer.h:15,
                 from tests/testNDTMvsTMCloverFull.cc:24:
include/qphix/tm_clov_dslash_body.h:1817:10: note: candidate: void QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::two_flav_achimbdpsi(QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::FourSpinorBlock**, const FourSpinorBlock**, const FourSpinorBlock**, const SU3MatrixBlock*, QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::FullCloverBlock* (*)[2], double, double, int, int) [with FT = float; int veclen = 8; int soalen = 4; bool compress12 = true; QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::FourSpinorBlock = float [3][4][2][4]; QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::SU3MatrixBlock = float [8][2][3][2][8]; QPhiX::TMClovDslash<FT, veclen, soalen, compress12>::FullCloverBlock = QPhiX::Geometry<float, 8, 4, true>::FullCloverBlock]
     void TMClovDslash<FT, veclen, soalen, compress12>::two_flav_achimbdpsi(
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/qphix/tm_clov_dslash_body.h:1817:10: note:   no known conversion for argument 5 from 'FullClover** [2] {aka QPhiX::Geometry<float, 8, 4, true>::FullCloverBlock** [2]}' to 'QPhiX::TMClovDslash<float, 8, 4, true>::FullCloverBlock* (*)[2] {aka QPhiX::Geometry<float, 8, 4, true>::FullCloverBlock* (*)[2]}'

核心似乎是它无法将FullClover** [2]转换为 FullCloverBlock* (*)[2]。带括号的语法对我来说是新的。什么 这是什么意思?

以下是我认为应该做同样事情的最小例子。 但是,编译并没有失败。

struct FullClover {
    int x;
};

void achimdpsi(FullClover *clov[2][2]) {}

int main(int argc, char **argv) {
    FullClover *A;
    FullClover *clov_packed[2][2];
    clov_packed[0][0] = A;
    clov_packed[0][1] = A;
    clov_packed[1][0] = A;
    clov_packed[1][1] = A;

    int cb;
    FullClover **two_flav_clover[2] = {clov_packed[cb], clov_packed[cb]};

    achimdpsi(clov_packed);
}

因此我不确定这里会发生什么,最小的例子应该显示出来 相同的错误,如果问题确实是类型。

这里发生了什么?我该如何解决这个问题?

0 个答案:

没有答案