mercredi 7 juin 2017

std::is_member_function_pointer and const qualified member function

Consider the following structure named X:

struct X {
    void foo() const {}
};

Suppose we want to apply std::is_member_function_pointer for X::foo:

std::is_member_function_pointer<decltype(&X::foo)>

According to the possible implementation which is mentioned on cppreference.com std::is_member_function_pointer_helper structure template specialization will be instatiated:

template< class T, class U>
struct is_member_function_pointer_helper<T U::*> : std::is_function<T> {};

Now U and T are deduced for X and void() const respectively. The deduction of type U is pretty clear. But what is void() const type?

I know about constant methods, but there is no such thing like constant function, so the deduction of type T confuses me a bit.

Interestingly, there are specializations of std::is_function to deal with such types which are used in conjuction with std::is_member_function_pointer to detect member functions...

Aucun commentaire:

Enregistrer un commentaire