By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,435 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,435 IT Pros & Developers. It's quick & easy.

address of virtual member function passed as template argument

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.