Another Template bug ?

Mark Mitchell mmitchell@usa.net
Mon Jan 5 10:14:00 GMT 1998


>>>>> "Munagala" == Munagala V S Ramanath <ram@netcom.com> writes:

    Munagala> Hi,

    Munagala> The following template results in an inexplicable parse
    Munagala> error when compiled with egcs-1.0. A lot of code depends
    Munagala> on this construct of being able to access the
    Munagala> 'value_type', 'key_type' and other such types from STL
    Munagala> containers, so I'd appreciate any pointer on getting
    Munagala> this to work.

    Munagala> It works fine with gcc-2.7.2:

    Munagala> ------------------------------------------------------------------------
    Munagala> template< class T1, class T2 > void PushBack( T1 *p, T2
    Munagala> &c ) { T2::value_type wrp( p ); c.push_back( wrp ); }
    Munagala> ------------------------------------------------------------------------

    Munagala> When I compile with egcs-1.0, I get this:

    Munagala> ram@dust tests: /d2a/exper/bin/gcc bug3.C -lstdc++
    Munagala> bug3.C: In function `void PushBack(T1 *, T2 &)':
    Munagala> bug3.C:4: parse error before `('

This is not a bug.  You must say 

  typename T2::value_type wrp (p)

according to the standard.

    Munagala> Thanks.

    Munagala> Ram

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu




More information about the Gcc-bugs mailing list