<分区>
假设我有类型 bar
和 foo
.如何构建模板类 has_call_with_arg<>
这样 has_call_with_arg<bar,foo>::value
为真当且仅当
bar b;
foo f;
b(f);
会编译吗?我调查了各种相关问题(包括上面提到的)并尝试了
template<typename Func, typename Arg>
class has_call_with_arg
{
struct bad {};
struct test : Func
{
template<typename C>
bad operator()(C const&r);
};
public:
static const bool value =
!std::is_same<bad, typename std::result_of<test(Arg const&)>::type >::value;
};
但这没有用(没有检测到正确的匹配项)。怎么了?