If I create a pointer element to the base, I can convert it to a pointer-to-derived member, as a rule, but not when used in a template, for example Buzz below, where the first argument of the template affects the second, I am struggling with compiler errors or Does this standard really not work?
struct Foo
{
int x;
};
struct Bar : public Foo
{
};
template<class T, int T::* z>
struct Buzz
{
};
static int Bar::* const workaround = &Foo::x;
int main()
{
int Bar::* y = &Foo::x;
Buzz<Bar, &Foo::x> test;
Buzz<Bar, static_cast<int Bar::*>(&Foo::x)> test;
Buzz<Bar, workaround> test;
return 0;
}
source
share