Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > address of virtual member function passed as template argument

Reply
Thread Tools

address of virtual member function passed as template argument

 
 
pascal.zschumme@gmail.com
Guest
Posts: n/a
 
      03-15-2007
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( : 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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      03-15-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> My problem is that the following code using something very very
> difficult technique 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


 
Reply With Quote
 
 
 
 
pascal.zschumme@gmail.com
Guest
Posts: n/a
 
      03-16-2007
On 15 Mrz., 21:33, "Victor Bazarov" <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > My problem is that the following code using something very very
> > difficult technique 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use the template member function of a template in the memberfunction of another template class? Peng Yu C++ 3 10-26-2008 03:51 PM
Template argument as template argument nw C++ 0 04-14-2008 01:36 PM
parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function! ken C++ 2 06-28-2005 06:57 AM
address-of a template class template member function Brian Riis C++ 3 11-02-2004 04:52 PM
Template function as argument to another template function Jim West C++ 3 10-07-2004 07:21 PM



Advertisments