我有以下代码作为实验:
int f1() { return 0; }
struct Bar {
Bar() = delete;
int f() { return 0; }
int operator()() { return 1; }
};
int main()
{
decltype(f1()) x = 3;//f1() is expression
result_of<decltype(&f1)()>::type x1 = 3;//type+param
result_of<Bar()>::type x3 = 3;//type+param
decltype(declval<Bar>().f()) y = 4;//expression
decltype((((Bar*)nullptr)->*(&Bar::f))()) z = 5;//expression
result_of<decltype(std::mem_fn(&Bar::f))()>::type y2 = 3;//error!!!!!!
}
一切都很好,除了最后一个result_of
:我试图获得返回类型Bar::f
,使用result_of
.
为什么它失败了,以及如何纠正它?