如何在C++中约束可调用对象的签名?

JAH*_*JAH 6 c++

template<typename TCallable>
void Fun(TCallable c){
...
}
Run Code Online (Sandbox Code Playgroud)

如何cint(double, double)不使用std :: function的情况下指示前面的代码中必须有一些特定的签名(比方说)?

MSa*_*ers 7

看起来你可以添加static_assert(std::is_same<decltype(c(0.0,0.0)), int>::value, "c must take two doubles and return int").