関数またはファンクターへのポインターで可能です (たとえば、boost から)。
次のようなことを試してください:
struct constrain{
string name;
int direction;
double (*evaluate) (vector <double> &x_var);
};
また
struct constrain{
string name;
int direction;
boost::function<double(vector &<double>)> evaluate;
};
これには、呼び出し元の「オブジェクト」へのポインターがないことに注意してください。そのため、適切なパラメーターを追加する必要があります (おそらく便宜上、型定義します)。
struct constrain{
typedef double (*callback_t) (constrain *obj, vector <double> &x_var);
string name;
int direction;
callback_t evaluate_f;
// helper function
double evaluate(vector <double> &x_var) {
return evaluate_f(this, x_var);
}
};
使用方法については、 http://ideone.com/VlAvDを確認してください。
boost::function
and boost::bind
(またはstd::*
C++11 でコンパイラを使用している場合は同等のもの) を使用すると、はるかに簡単になる可能性があります: http://ideone.com/wF8Bz