如何解决错误:"no matching function for call to ‘bind(<unresolved overloaded function type>"在类中使用 std
How to solve the error: "no matching function for call to ‘bind(<unresolved overloaded function type>" when std::bind is used in a class
通常,std::bind在boost::math::tools::bisect()中工作良好。但是,当我尝试在具有成员函数的类中使用std::bind时,总是出现错误:
没有匹配
bind(<unresolved overloaded function type>
…的函数
这是类的一个成员函数:
double SingleCapillaryTube::calLocationFunctionWithoutAngle(const TubeGeometry &TG,
const FluidProperties &FP, double tempLocation,
double initialLocationValue, double tempTime,
const double initialTimePoint)
{
auto coefficientB = calCoefficientB(TG, FP);
auto coefficientA = calCoefficientA(TG, FP);
auto coefficientD = calCoefficientD(TG, FP);
auto tempValue = -coefficientB * (tempLocation - initialLocationValue) -
1./2. * coefficientA * (pow(tempLocation, 2.) -
pow(initialLocationValue, 2.)) - coefficientD *
(tempTime - initialTimePoint);
return tempValue;
}
然后在类的另一个成员函数中使用这个函数:
void SingleCapillaryTube::calLocationInterfaceBisect()
{
stepResult = boost::math::tools::bisect(
std::bind(calLocationFunctionWithAngle,
Geometry, Fluids, _3, initialLocation,
timePoint, initialTime), 0.0,
-Geometry.length, Tol);
}
编译文件时,总是发生错误。有人能帮我解决这个问题吗?
非静态成员函数需要一个实例来调用。要给它,传递你的this
指针作为函数的第一个参数。您还需要使用函数的完整限定名并取其地址:
std::bind(&SingleCapillaryTube::calLocationFunctionWithAngle, this,
Geometry, Fluids, _3, initialLocation, timePoint, initialTime)
还请注意,使用_3
将第三个位置参数绑定到该参数,因此在这种情况下,第一个和第二个参数将被忽略。您可能希望_1
在该位置
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- 库函数需要一个 std::function<void(void)>,如何传入类函数?
- Confusion: decltype vs std::function
- 为什么 std::function 可以作为 std::not2 的参数?
- 'max'匹配'std::function<const int &(const int &, const int &)>'无过载
- 传递给std::function template的template参数究竟代表什么
- 将带有unique_ptr的可变 lambda 传递给 const&std::function
- 如何修复"unresolved external symbol _gladLoadGLLoader referenced in function _main"和"unresolved external
- "unresolved overloaded function type"错误并将运算符作为函数参数传递
- 'unresolved external symbol _SDL_main referenced in function' Visual Studio 2012 中的 SDL2 错误
- 在 std::function 中使用静态函数的"unresolved overloaded function type"
- "Unresolved overloaded function type"尝试将for_each与迭代器一起使用并在C++中发挥作用
- 链接器错误"... .obj : error LNK2019: unresolved external symbol referenced in function"
- 错误:调用'sort(..., ..., <unresolved overloaded function type>)'没有匹配函数
- 如何解决错误:"no matching function for call to ‘bind(<unresolved overloaded function type>"在类中使用 std
- 如何修复'unresolved overloaded function type?'
- 从 boost::thread 调用模板化函数时"unresolved overloaded function type"
- 调用'QDomDocument::createElement(<unresolved overloaded function type>)'没有匹配函数
- G++ 使用模板参数提供"unresolved overloaded function type"