Pointer to a template function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kufa

    #1

    Pointer to a template function

    Hi,

    I have nailed down a piece of code that is obviously wrong, but cannot
    find what i should i do to make it ansi compliant, neither where in
    the reference i should look.
    Basically i m trying to get a pointer on a static function of a
    template class:

    struct A
    {
    template< class Type1 struct B
    {
    template< bool B1, bool B2, bool B3 static void func( int, int )
    {}
    };

    template< class Type2 void test();
    };

    typedef void (*FuncType)(int ,int);

    template< class Type2 void A::test()
    {
    FuncType ptr = &B<Type2>::func <true,true,true >;
    ptr(0,0);
    }

    I know that specializing func outside B wouldnt be correct, but
    getting a pointer on it should be allright, right?

    Any help is welcome,
    Thanks,

    /david
  • Marco Manfredini

    #2
    Re: Pointer to a template function

    Kufa wrote:
    [...]
    typedef void (*FuncType)(int ,int);
    >
    template< class Type2 void A::test()
    {
    FuncType ptr = &B<Type2>::func <true,true,true >;
    try this:
    FuncType ptr = &B<Type2>::temp late func<true,true, true>;

    Comment

    • Kufa

      #3
      Re: Pointer to a template function

      On 23 nov, 00:04, Marco Manfredini <ok_nospam...@p hoyd.netwrote:
      try this:
      FuncType ptr = &B<Type2>::temp late func<true,true, true>;
      Hi Marco,

      That indeed did the trick, thx alot :)

      Comment

      • Kira Yamato

        #4
        Re: Pointer to a template function

        On 2007-11-22 18:04:26 -0500, Marco Manfredini <ok_nospam_ok@p hoyd.netsaid:
        Kufa wrote:
        [...]
        >typedef void (*FuncType)(int ,int);
        >>
        >template< class Type2 void A::test()
        >{
        > FuncType ptr = &B<Type2>::func <true,true,true >;
        try this:
        FuncType ptr = &B<Type2>::temp late func<true,true, true>;
        o_O

        C++ truly is a complicated language. It's almost like physics: The
        more I learn about it, the more I feel I don't know it.

        --

        -kira

        Comment

        Working...