我无法访问指向成员的指针.为什么?

Ale*_*tov 8 c++ templates pointer-to-member

请考虑以下代码:

template<class T, class F>           struct X {};
template<class T, class F, T F::* m> struct Y {};

struct Foo {
    int member;
    typedef X<int, Foo>               x_type; // works well
    typedef Y<int, Foo, &Foo::member> y_type; // ERROR
};

typedef Y<int, Foo, &Foo::member> y_type2; // OK
Run Code Online (Sandbox Code Playgroud)

为什么编译器会生成错误?(VS2008)


新

我已将此错误发布到connect.microsoft.com.

Kir*_*sky 7

我认为它与某种方式有关,因为Visual C++在那一点上不知道指向成员的指针的大小.例如,检查此缺陷报告(这是指向成员变量的指针的另一个问题).我认为你发现了另外一个Visual C++错误,它应该报告给connect.microsoft.com.


Ale*_*tov 1

这是一个错误