In the context of creating a hopefully better OO wrapper around the nlopt optimization library where the objective and constraint functions signature and implementation can be defined using Eigen types I have the following problem:
This compiles:
namespace nlopt {
template <class Data>
struct Oracle {
typedef boost::tuple<double, VectorXd> (*f_t) (const VectorXd&, Data& data);
typedef boost::tuple<VectorXd, MatrixXd> (*mf_t)(const VectorXd&, Data& data);
};
};
/// Concrete Nlopt adapter search space implementation.
/**
* Concrete Nlopt adapter search space implementation.
*/
template <class ConstraintData>
class NloptSpace : public ContinuousSpaceInterface<double, VectorXd> {
public:
/// nonlinear constraints
struct NonlinearConstraint {
typename nlopt::Oracle<ConstraintData>::f_t func_; ConstraintData* data_; double tol_;
NonlinearConstraint(typename nlopt::Oracle<ConstraintData>::f_t func, ConstraintData* data, double tol) {
func_ = func;
data_ = data;
tol_ = tol;
}
};
// ...
};
typedef typename NloptSpace<ConstraintData>::NonlinearConstraint NonLinearConstraint;
const std::vector<NonLinearConstraint>& inequality_constraints = space.inequality_constraints();
However, this extra line does not compile and gives me the following totally uninformative error:
std::vector<NonLinearConstraint>::const_iterator iter;
error: expected a ";"
std::vector<NonLinearConstraint>::const_iterator iter;
^
btw just in case you are wondering whether I have the correct includes this also compiles:
std::vector<int>::const_iterator iter;
and this also compiles:
inequality_constraints.begin(); // can't assign it to anything without the compiler error
Somehow the compiler doesn't like the NonLinearConstraint
template as a vector const iterator but it really doesn't give any hint as to what's wrong.
I don't expect anyone to help me fix the issue here but to give me a pointer how to get more information on this compiler error.