C++ Templates, typedefs, default template parameters

Jonathan.R.Essex@BankAmerica.com Jonathan.R.Essex@BankAmerica.com
Sat Oct 17 04:57:00 GMT 1998


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 default
template parameters. For example:

template< class T >
class allocator
{
public:
  typedef T* pointer;
  //etc
};

template< class T, class A = allocator< T > >
class block
{
public:
   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, to
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. (yes,
the strange SGI flavour works fine and is in many senses better but that's
not what I want; I have a moderately large body of code already written the
 standard way)

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

Regards,
Jonathan Essex.





More information about the Gcc-bugs mailing list