C++ &引用;“不完整类型的无效使用”;for const函数指针类型作为模板参数

C++ &引用;“不完整类型的无效使用”;for const函数指针类型作为模板参数,c++,c++11,C++,C++11,考虑函子包装器的以下简化代码: #包括 #include//std::forward 模板 结构返回类型; 模板 结构返回类型{ typedef-R型; }; // ---------------------- 模板 类函子{ 公众: 函数型*f; 函数指针类型p; 函子包装器(FunctionPointerType pp):p(pp){f=新函子类型;} 模板 typename返回类型::类型运算符()(A&&…args){ 返回((f->*p)(标准::正向(参数)…); } }; // -

考虑函子包装器的以下简化代码:

#包括
#include//std::forward
模板
结构返回类型;
模板
结构返回类型{
typedef-R型;
};
// ----------------------
模板
类函子{
公众:
函数型*f;
函数指针类型p;
函子包装器(FunctionPointerType pp):p(pp){f=新函子类型;}
模板
typename返回类型::类型运算符()(A&&…args){
返回((f->*p)(标准::正向(参数)…);
}
};
// ----------------------
少给我上课{
公众:

bool non_const_mem(const int&x,const int&y){return x您缺少合适的限定模板专门化,如下所示:

template <class R, class C, class... A>
struct return_type <R (C::*)(A...) const> {
    typedef R type;             // ^^^^^
};
模板
结构返回类型{
typedef R type;//^^^^^
};

是否有任何理由不简单地使用
std::function
?它与成员函数指针同样有效。