Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can not get access to pointer to member. Why?

Consider the following code:

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

Why does compiler generate error? (VS2008)


New

I have posted this bug to connect.microsoft.com.

like image 291
Alexey Malistov Avatar asked Nov 26 '09 08:11

Alexey Malistov


2 Answers

I think that it is related somehow with that Visual C++ don't know the size of pointer to member at that point. Check this defect report for instance (here is another problem with pointer to member variable). I think that you found one more Visual C++ bug and it should be reported to connect.microsoft.com.

like image 57
Kirill V. Lyadvinsky Avatar answered Oct 22 '22 13:10

Kirill V. Lyadvinsky


This is a bug

like image 24
Alexey Malistov Avatar answered Oct 22 '22 13:10

Alexey Malistov