address of virtual member function passed as template argument

P

pascal.zschumme

hello folks

My problem is that the following code using something very very
difficult technique :D 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
 
V

Victor Bazarov

My problem is that the following code using something very very
difficult technique :D fails to compile on MSVC8:
<code> [..]
</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?

You seem to have a problem with a particular compiler. Please consider
posting your inquiry to the compiler's newsgroup (take a closer look at
the microsoft.public.vc.* hierarchy of newsgroups).

V
 
P

pascal.zschumme

My problem is that the following code using something very very
difficult technique :D fails to compile on MSVC8:
<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?

You seem to have a problem with a particular compiler. Please consider
posting your inquiry to the compiler's newsgroup (take a closer look at
the microsoft.public.vc.* hierarchy of newsgroups).

V

thank you, i posted it on microsoft.public.vc.language
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top