I see no reason.
Look at this:
typedef void Func(); Func freeFunction; struct Foo { Func memberFunction; };
freeFunction Announcement Func freeFunction; . So decltype(freeFunction) is void() , i.e. Func .
Using the same logic, As Foo::memberFunction also declared as Func , I expect decltype(Foo::memberFunction) be Func too. But this is not so, as it does not compile.
Just like int a; decltype(a) int a; decltype(a) resolves int , even if int a; is a member, decltype(Foo::memberFunction) should be fine.
Note that qualifiers can also be processed, there is nothing special about them (of course, in this case Func can only be used to declare non-static member functions):
typedef void Func() const volatile &&; struct Foo { Func memberFunction; };
Here I expect decltype(Foo::memberFunction) be void() const volatile && , so I can copy its declaration:
struct Bar { decltype(Foo::memberFunction) myMemFn; };
Quote from the C ++ 14 standard (9.2 / 11):
[Note. The type of the non-static member function is the regular type of the function, and the type of the non-static member is the regular type of the object. There are no special types of member functions or data types. - final note]
This quote means that it would be reasonable if decltype(<member_function>) returned the type of a regular function.
geza
source share