I have functions of the form:
num_t foo1(num_t a, num_t b, num_t c);
num_t foo2(num_t a, num_t b, num_t c);
...
and I want to create functions of the form
void bar1(struct value *p);
void bar2(struct value *p);
...
via some kind of transformation function ff3a(). bar1(), bar2() will be put in a lookup table.
My effort so far is:
using ff3_sig = std::function<num_t(num_t, num_t, num_t)>;
void ff3(ff3_sig &f, struct value* p)
{
num_t a = p->Float, b = (p+1)->Float, c = (p+2)->Float;
num_t res = f(a, b, c);
p->Float = res;
}
std::function<void(struct value* p)>
ff3a(ff3_sig &f)
{
auto g = [&](struct value* p) { ff3(f, p); };
return g;
}
However, when I call ff3a(foo1) I get the error message:
error: cannot bind non-const lvalue reference of type
‘ff3_sig& {aka std::function<<unnamed-float:64>(<unnamed-float:64>,
<unnamed-float:64>, <unnamed-float:64>)>&}’ to an rvalue of type
‘ff3_sig {aka std::function<<unnamed-float:64>(<unnamed-float:64>,
<unnamed-float:64>, <unnamed-float:64>)>}’
Aucun commentaire:
Enregistrer un commentaire