469,962 Members | 2,341 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,962 developers. It's quick & easy.

address of virtual member function passed as template argument

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::f1h1; // other class, normal function
-works
memfuncaddr_holder<Foo, &Foo::f2h2; // other class, virtual
function -works
memfuncaddr_holder<Boom, &Boom::f1h3; // same class, normal
function -works
memfuncaddr_holder<Boom, &Boom::f2h4; // 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

Mar 15 '07 #1
2 1851
pa*************@gmail.com wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Mar 15 '07 #2
On 15 Mrz., 21:33, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
pascal.zschu...@gmail.com wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
thank you, i posted it on microsoft.public.vc.language

Mar 16 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ivan | last post: by
11 posts views Thread by santosh | last post: by
7 posts views Thread by Markus Svilans | last post: by
11 posts views Thread by mathieu | last post: by
13 posts views Thread by Mike -- Email Ignored | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.