P
pascal.zschumme
hello folks
My problem is that the following code using something very very
difficult technique fails to compile on MSVC8:
<code>
// main.cpp
//
// the error is:
// main.cpp(8) : fatal error C1001: internal compiler error.
// (File "msc1.cpp", Line 1392)
#include <iostream>
// just a simple class template which "holds" an address of a member
function
// i found out that this class doesn't even need to contain anything
else than this to produce the error
template<class Class, void(Class::*MemberFunction)()>
class memfuncaddr_holder
{
};
class Foo
{
public:
void f1() {}
virtual void f2() {}
};
class Boom
{
public:
// note: it is important that h1-h4 are in the same class than
Boom::f1 and Boom:f2
void f1() {}
virtual void f2() {}
memfuncaddr_holder<Foo, &Foo::f1> h1; // other class, normal function
-> works
memfuncaddr_holder<Foo, &Foo::f2> h2; // other class, virtual
function -> works
memfuncaddr_holder<Boom, &Boom::f1> h3; // same class, normal
function -> works
memfuncaddr_holder<Boom, &Boom::f2> h4; // same class, virtual
function -> internal compiler error
};
int main(int argc, char* argv[])
{
return 0;
}
</code>
The Code works with gcc4.
The problem is that i can't pass the address of a virtual member
function of a class (here Boom) to a member variable in the same class
as template parameter
Do you guys know any solutions to solve this?
I'm looking forward to read your answers
thanks, pyrokar
My problem is that the following code using something very very
difficult technique fails to compile on MSVC8:
<code>
// main.cpp
//
// the error is:
// main.cpp(8) : fatal error C1001: internal compiler error.
// (File "msc1.cpp", Line 1392)
#include <iostream>
// just a simple class template which "holds" an address of a member
function
// i found out that this class doesn't even need to contain anything
else than this to produce the error
template<class Class, void(Class::*MemberFunction)()>
class memfuncaddr_holder
{
};
class Foo
{
public:
void f1() {}
virtual void f2() {}
};
class Boom
{
public:
// note: it is important that h1-h4 are in the same class than
Boom::f1 and Boom:f2
void f1() {}
virtual void f2() {}
memfuncaddr_holder<Foo, &Foo::f1> h1; // other class, normal function
-> works
memfuncaddr_holder<Foo, &Foo::f2> h2; // other class, virtual
function -> works
memfuncaddr_holder<Boom, &Boom::f1> h3; // same class, normal
function -> works
memfuncaddr_holder<Boom, &Boom::f2> h4; // same class, virtual
function -> internal compiler error
};
int main(int argc, char* argv[])
{
return 0;
}
</code>
The Code works with gcc4.
The problem is that i can't pass the address of a virtual member
function of a class (here Boom) to a member variable in the same class
as template parameter
Do you guys know any solutions to solve this?
I'm looking forward to read your answers
thanks, pyrokar