How do you get a member function type

The question is based on a note in the standard [class.mem]

The type of a non-static member function is a regular type of function, and the type of a non-static data element is a regular type of object. There are no special types of member functions or types of data items.

So, I decided to check it out

struct S { using Fn = void(); Fn foo; static_assert(std::is_same_v<decltype(foo), Fn>); }; 

But its error in decltype(foo) : invalid use of a non-static member.

How do you get the type of a member function? Or is the note simply fictitious?

Note. This must be done for data members.

 struct U { int i; static_assert(std::is_same_v<decltype(i), int>); }; 

Note2: I am not looking for how to capture a type using an element pointer

 template<typename> struct NotLikeThis; template<typename C, typename R, typename... Args> struct NotLikeThis<R (C::*)(Args...)> { using type = R(Args...); }; 

A note of the standard does not apply to this.

+6
c ++ language-lawyer
source share

No one has answered this question yet.

See similar questions:

7
Is there a reason why we cannot name a non-stationary member function in an invaluable context?
0
What are the properties of the category of values โ€‹โ€‹of member functions in C ++ 11?

or similar:

2873
How do I iterate over the words of a string?
2416
How do you set, clear and switch one bit?
1783
C ++ 11 introduced a standardized memory model. What does it mean? And how will this affect C ++ programming?
385
Static constant string (class member)
8
std :: async call a member function
5
Can we access a member of a non-existent union?
2
Class member pointer
2
C ++ Union, two active participants, differing only in CV qualifications
2
Do scalar members in a union form a common initial sequence?
one
Checking inactive union members, general initial sequence

All Articles