【发布时间】:2016-04-13 15:24:52
【问题描述】:
我可以执行以下操作来检测某个东西是否是函数:
void f()
{
}
int main()
{
std :: cout << std :: is_function <decltype(f)> :: value << std :: endl; // true
}
现在,如果我想做同样的事情,但函数是类的方法,会发生什么?
我天真地试图做类似的事情
class myclass
{
public:
void f()
{
}
};
int main()
{
std :: cout << std :: is_function <decltype(myclass :: f)> :: value << std :: endl;
}
但我明白了
Call to non-static member function without an object argument
我该怎么办?我想要类似上面的东西......好吧,只打印true。
【问题讨论】:
-
这确实是过多的间距。
标签: c++ function templates std