Calling templated member of templated object

Discussion in 'C++' started by david@sunlightd.com, Jun 22, 2007.

  1. Guest

    template< typename T >
    void f( T & t )
    {
    t.g<int>();
    }

    MSVC 2005 compiles this without problems (yes, even when it's
    instantiated). g++ gives errors. Comeau compiles in "relaxed" mode,
    but in "strict" mode gives

    "ComeauTest.c", line 4: error: type name is not allowed
    t.g<int>();
    ^

    "ComeauTest.c", line 4: error: expected an expression
    t.g<int>();
    ^

    Clearly, it's assuming the < is a less-than operator. What is the
    "strict" way of doing this?
    --
    David
     
    , Jun 22, 2007
    #1
    1. Advertising

  2. Guest

    On Jun 22, 10:03 am, wrote:
    > template< typename T >
    > void f( T & t )
    > {
    > t.g<int>();
    >
    > }

    try

    void f( T & t )
    {
    t.template g<int>();

    }


    >
    > MSVC 2005 compiles this without problems (yes, even when it's
    > instantiated). g++ gives errors. Comeau compiles in "relaxed" mode,
    > but in "strict" mode gives
    >
    > "ComeauTest.c", line 4: error: type name is not allowed
    > t.g<int>();
    > ^
    >
    > "ComeauTest.c", line 4: error: expected an expression
    > t.g<int>();
    > ^
    >
    > Clearly, it's assuming the < is a less-than operator. What is the
    > "strict" way of doing this?
    > --
    > David
     
    , Jun 22, 2007
    #2
    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. RA Scheltema
    Replies:
    3
    Views:
    406
    RA Scheltema
    Jan 6, 2004
  2. Marijn
    Replies:
    5
    Views:
    465
    Marijn
    Feb 13, 2004
  3. Replies:
    0
    Views:
    2,236
  4. Jahagirdar Vijayvithal S
    Replies:
    2
    Views:
    435
    Jahagirdar Vijayvithal S
    Aug 7, 2005
  5. chhenning
    Replies:
    5
    Views:
    366
    chhenning
    Feb 13, 2008
Loading...

Share This Page