缺少模板参数或所需的主表达式
Missing template arguments or expected primary expression
我正试图用一个开源库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
相关文章:
- 概念中的cv限定符需要表达式参数列表
- 在函数中使用 const int size 参数创建数组会在 Visual Studio 中抛出错误 C++:表达式的计
- 表达式 SFINAE:如何根据类型是否包含具有一个或多个参数的函数来选择模板版本
- 使用自动推导的 lambda 参数作为常量表达式
- 编译器是否强制根据模板参数计算表达式?
- 错误:参数中无效地使用了无效表达式
- 将折叠表达式传递给可变参数模板
- 为什么带有指针子对象的文字类类型的 constexpr 表达式不能是非类型模板参数
- C++: priority_queue:模板参数中的 lambda 表达式
- 容器如何处理 lambda 表达式的参数
- 在C++ Lambda 表达式中,为什么人们更喜欢按值捕获而不是作为参数传递?
- 整体模板参数。错误:在常量表达式中使用'this'
- 我可以std::在fold表达式中转发参数吗
- 折叠表达式模板参数推导/替换失败
- 折叠表达式和参数包:static_assert 内 Args&& 和 Args 之间的区别
- C++:从捕获函数参数的函数返回 lambda 表达式
- 是否可以使用带有模板化参数的特征块表达式作为左值?
- 编译器在传递 const 变量时返回错误:模板参数不是常量表达式
- 表达式参数在 C++ 中有什么用
- 类表达式参数定义不正确