I have some trouble using decltype
for member function pointers:
#include <iostream>
#include <type_traits>
struct A
{
void func1() {}
typedef decltype(&A::func1) type;
};
int wmain(int argc, wchar_t* argv[])
{
typedef decltype(&A::func1) type;
//Case 1
std::wcout
<< std::boolalpha
<< std::is_member_function_pointer<type>::value
<< std::endl;
//Case 2
std::wcout
<< std::boolalpha
<< std::is_member_function_pointer<A::type>::value
<< std::endl;
system("pause");
return 0;
}
Case 1 prints true
as expected, but Case 2 prints false
.
Is decltype
stripping away the "member" property of a type? If so, why?
Also, is there a way to prevent this behavior? I need to get the type of a member function regardless of where I use decltype
.
Please help.
EDIT:
Reported to Microsoft
For the sake of formality (having an answer to the question), this appears to be a bug in VC2010's compiler. File a bug report so that Microsoft can fix it in the next version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With