Reputation: 803
I'm using Eigen in a class that I'm working on. Here's the code excerpt:
class model {
public:
Eigen::MatrixXd Ac;
model (vars &, std::function<Eigen::MatrixXd()>, std::function<Eigen::MatrixXd()>);
};
model::model (vars & vars, std::function<Eigen::MatrixXd()> muX,
std::function<Eigen::MatrixXd()> muX2)
//update Ac
Ac = muX(vars) + muX2(vars);
};
The idea is that when creating an object of model
, the user will have to supply the functions muX
and muX2
, and the class will fill in values in MatrixXd Ac
using muX
and muX2
. vars
is just a class consisting of multiple variables that I created, and muX
and muX2
are expected to use the data in vars
as input.
However, in my XCode, it's giving me an error saying: "No matching function for call to object of type `std::function". I haven't compiled yet but I think the compiler will give me the same error.
Upvotes: 0
Views: 42
Reputation: 1158
std::function<Eigen::MatrixXd()>
implies that it takes a function which accepts no arguments and returns an Eigen::MatrixXd
, which I think is not what you want to do. You probably want to change it to std::function<Eigen::MatrixXd(vars&)>
Upvotes: 1