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"
in
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
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.
ÃÂ
--ÃÂ
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