template <typename Function>
struct function_traits : public function_traits < decltype(&Function::operator()) >
{
};
template <typename ClassType, typename ReturnType, typename Args>
struct function_traits < ReturnType(ClassType::*)(Args) const >
{
typedef ReturnType(*pointer)(Args);
typedef std::function<ReturnType(Args)> function;
};
测试代码:
class A
{
public:
void Test(int aaaa)
{
}
};
A a;
std::function<void(int)> f = std::bind(&A::Test, a, std::placeholders::_1);
std::string name = typeid(function_traits<decltype(f)>::pointer).name();
时间: 2024-10-07 15:51:28