开发者

Using decltype with member function pointers

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜