C++ Templates, typedefs, default template parameters

Eric Darve darve@ann.jussieu.fr
Sat Oct 17 10:04:00 GMT 1998

    You need to add "typename" in front of "allocator_type::pointer"
typedef allocator_type::pointer pointer_type;

    It should be
typedef typename allocator_type::pointer pointer_type;

By the way what error message did you get?

With egcs 1.1 I have
bug.cc:14: `A::pointer' is not a valid declarator
bug.cc:14:   perhaps you want `typename A::pointer' to make
it a type
bug.cc:14: parse error before `;'
bug.cc:16: syntax error before `;'

which correctly points out the missing typename.

    Best regards,    Eric

Jonathan.R.Essex@BankAmerica.com wrote:
I'm sorry if this has been submitted before; If anyone
can tell me of a
_searchable_ archive of this mailing list I will gladly shut up.

I've just downloaded/compiled egcs 1.1b; This is the first time I've
seriously experimented with any GNU-related compiler. I want to use
something resembling the standard template library allocators (okay,
I may
be a couple of drafts out of date), which really require the use of
template parameters. For example:

template< class T >
class allocator
  typedef T* pointer;

template< class T, class A = allocator< T > >
class block
   typedef A allocator_type;
   typedef allocator_type::pointer pointer_type;

  pointer_type pBuffer;

// etc


the compiler doesn't complain about the default template parameter (as,
be honest, I have come to expect). Instead, it reports:

'A::pointer' is not a valid declarator.

This would appear to make it impossible to use standard allocators.
the strange SGI flavour works fine and is in many senses better but
not what I want; I have a moderately large body of code already written
 standard way)

All this compiles fine on MSVC 5.0. _HORROR_ Can Microsoft really be
sticking to a standard more closely than GNU?

Jonathan Essex.
Travail  : (331) 44 27 27 17 (work)
Domicile : (331) 40 78 50 33 (home)
Fax      : (331) 44 27 72 00
Adresses : 
** Ch. 114
   Maison Néerlandaise
   Cité Universitaire Internationale
   61, bd Jourdan
   75014 Paris
** Université Pierre et Marie Curie
   Laboratoire d'Analyse Numerique
   Tour 55-65, 5ième étage
   4 Place Jussieu 75252 Paris

More information about the Gcc-bugs mailing list