【发布时间】:2015-05-05 21:50:17
【问题描述】:
我的代码 -
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
#include "boost\numeric\ublas\matrix.hpp"
typedef boost::numeric::ublas::matrix<float> matrix;
class FillMat{
public:
FillMat(float valIn) : val(valIn){}
float operator()(float in) {
val = in + 1;
return val;
}
private:
float val;
};
typedef boost::numeric::ublas::matrix<float> matrix;
int main(){
matrix m1(10, 20);
float init = 22.2;
FillMat myFiller(init);
generate(m1.begin2(), m1.begin2() + m1.size1()*m1.size2(), myFiller);
return 0;
}
当我尝试编译代码时,出现以下编译时错误。
Error 3 error C2064: term does not evaluate to a function taking 0 arguments
谁能告诉我为什么?
附:我添加了标题。我正在将 Boost 矩阵用于 2D 数组。
【问题讨论】:
-
你不能提供一个 MCVE 吗?我们甚至不知道该错误是在哪一行生成的......
-
@LightnessRacesinOrbit 我将尝试使用矢量。会这样吗?
-
这对什么有用吗?你还没有告诉我们你想要做什么......
-
Boost 使用不是你的测试用例出了什么问题,而是缺少标题等。一个好的测试用例是一个允许我们复制粘贴和编译的测试用例,而不必猜测是什么我们可能需要包含的标题。
-
@LightnessRacesinOrbit 我正在尝试用递增值填充容器的内容
标签: c++ c++11 functor standard-library