#include <type_traits>
#include <stdio.h>
void f() { printf("foo\n"); }
int main()
{
printf("%d %d %d\n",
std::is_same<decltype(*&f),decltype(f)>::value,
std::is_function<decltype(*&f)>::value,
std::is_function<decltype(f)>::value);
(*&f)();
return 0;
}
其產生
0 0 1
foo
對於g ++ 4.6.1和4.7.0。
任何人都可以解釋這一點嗎?
我敢打賭'*&f'是一個引用類型。 – 2012-02-27 17:17:50
賓果! std :: remove_reference <...>會訣竅! – smilingthax 2012-02-27 17:19:40