我正在做一些看起来像这样的包装器:
#include <iostream>
template<class T, class Value>
void Apply(void (T::*cb)(Value), T* obj, Value v)
{
(obj->*cb)(v);
}
class Foo
{
public:
void MyFunc(const int& i)
{
std::cout << i << std::endl;
}
const int& GetValue()
{
return i_;
}
private:
int i_ = 14;
};
int main()
{
Foo f;
Apply(&Foo::MyFunc, &f, f.GetValue());
}
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
Apply:找不到匹配的重载函数. void Apply(void (__thiscall T::* )(Value),T *,Value):模板参数Value不明确,可能是int或const int &. void Apply(void (__thiscall T::* )(Value),T *,Value):无法推断Value …c++ templates ambiguous ambiguous-call template-argument-deduction
VS2017可以安装标准库模块.
实际上Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\ifc\有ifc模块定义文件和std.libx86/x64和Debug/Release.我们如何使用它们?你如何与他们联系?这些标准模块到底有哪些?