相关疑难解决方法(0)

组合std :: function对象

说我有

double xSquared( const double )
{
    return x*x;
}

...
std::function<double (double)> func = &xSquared;
...
Run Code Online (Sandbox Code Playgroud)

到目前为止,我使用这种结构的(更复杂的)目的很好.现在我有一个接受上述形式的std :: function的函数,我需要创建一个扩展原始的新的std :: function:

typedef std::function<double (double)> func1D;

double someFunction( const func1D &func, const double a )
{
    func1D extendedFunc = func/(x-a); // I know this is incorrect, but how would I do that?
    ...
}
Run Code Online (Sandbox Code Playgroud)

所以数学等价物是:

f(x)=x²

g(x)= f(x)/(xa)

我怎么能做到这一点?谢谢您的帮助!

c++ functional-programming c++11

2
推荐指数
1
解决办法
1161
查看次数

标签 统计

c++ ×1

c++11 ×1

functional-programming ×1