使用带有虚拟成员函数指针的decltype

Nub*_*ase 6 c++ visual-studio visual-c++ c++11

使用decltype虚拟成员函数指针是否合法?

以下内容使用VS2012生成内部错误(C1001).

struct C
{
    virtual void Foo() {}

    typedef decltype(&C::Foo) type;   //pointer
}
Run Code Online (Sandbox Code Playgroud)

但这编译很好:

struct C
{
    virtual void Foo() {}

    typedef decltype(C::Foo) type;   //not pointer
}
Run Code Online (Sandbox Code Playgroud)

这是一个错误吗?

eca*_*mur 4

decltypeMSVC 在成员函数指针方面存在多个已知问题;另请参见将 decltype 与成员函数指针结合使用

这是合法的语法;g++ 对此非常满意(http://ideone.com/sTZi6)。标准中没有任何内容限制decltype成员函数的操作。