address of virtual member function passed as template argument

Discussion in 'C++' started by pascal.zschumme@gmail.com, Mar 15, 2007.

  1. Guest

    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
     
    , Mar 15, 2007
    #1
    1. Advertising

  2. 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
     
    Victor Bazarov, Mar 15, 2007
    #2
    1. Advertising

  3. Guest

    On 15 Mrz., 21:33, "Victor Bazarov" <> wrote:
    > 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, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim West
    Replies:
    3
    Views:
    781
    Jim West
    Oct 7, 2004
  2. Brian Riis
    Replies:
    3
    Views:
    509
    Brian Riis
    Nov 2, 2004
  3. Replies:
    1
    Views:
    481
    Victor Bazarov
    Jul 20, 2005
  4. nw
    Replies:
    0
    Views:
    334
  5. Peng Yu
    Replies:
    3
    Views:
    801
    Thomas J. Gritzan
    Oct 26, 2008
Loading...

Share This Page