Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using decltype with virtual member function pointers

Is it legal to use decltype with virtual member function pointers?

The following generates an internal error (C1001) with VS2012.

struct C
{
    virtual void Foo() {}

    typedef decltype(&C::Foo) type;   //pointer
}

But this compiles fine:

struct C
{
    virtual void Foo() {}

    typedef decltype(C::Foo) type;   //not pointer
}

Is it a bug?

like image 998
Nubcase Avatar asked Jul 05 '12 15:07

Nubcase


1 Answers

MSVC has multiple known issues with decltype to member function pointers; see also Using decltype with member function pointers

This is legal syntax; g++ is perfectly happy with it (http://ideone.com/sTZi6). There is nothing in the standard to restrict the operation of decltype on member functions.

like image 188
ecatmur Avatar answered Oct 26 '22 17:10

ecatmur