缺少模板参数或所需的主表达式

Missing template arguments or expected primary expression

本文关键字:表达式 参数      更新时间:2023-10-16

我正试图用一个开源库MMSP编写一个程序。我写了以下两个文件

#include<update.hpp>

int main(int argc, char** argv)
{
    MMSP::Init(argc,argv);
    std::cout<<"Hello MMSP"<<std::endl;
    MMSP::grid<2,double> GRID(argv[1]);
    update(grid,atoi(argv[3]));
    output(GRID,argv[2]);
    MMSP::Finalize();
    return 0;
}

这是更新的.hpp.

#include "MMSP.hpp"
 using namespace MMSP;
template<class T,class S>
void update(T& GRID, S steps)
{
    grid<2,double>update(GRID);
    for(int step=0;step<steps;step++){
            for (int x=x0(GRID);x<x1(GRID);x++)
                    for (int y=y0(GRID);y<y1(GRID);y++){
                    update[x][y]=GRID[x][y];
                    }
            swap(GRID,update);
            ghostswap(GRID);
     }
}

但我总是犯以下错误。

main.cpp:11: error: expected primary-expression before ‘,’ token

我哪里错了?

您有一个打字错误:

update(grid,atoi(argv[3]));
//     ^^^^ this is the name of a class template

应该是

update(GRID,atoi(argv[3]));
//     ^^^^ this is the name of an instance of class template grid