aren't specialized templates templates?

Gabriel Dos Reis gdr@integrable-solutions.net
Sun Feb 13 17:50:00 GMT 2005


Tim Janik <timj@gtk.org> writes:

| hi all.
| 
| the code snippet below is extracted from a much more
| complicated piece of code. basically the problem is that
| g++ (3.3 and 3.4) demand different typedef syntax inside
| template bodies, depending on whether full or partial
| specialization is used.
| 
| is this really the correct behaviour and standard conform?

Yes.  An explicit specialization is not a template.  Therefore line20
is in error.

| (to me it seems, line20 should still be considered part of
| a template and thus accept the "typename")
| 
| --------------------snip---------------------
| template<class C>
| struct Base {
|    typedef C* Iterator;
| };
| 
| template<class C, class D>
| struct Derived : Base<D> {
|    typedef typename Base<D>::Iterator Iterator;
| };
| 
| #define BASE_ITER(BASE)     typename BASE :: Iterator
| 
| template<class D>
| struct Derived<char, D> : Base<D> {
|    typedef BASE_ITER (Base<D>) Iterator;         // line15
| };
| 
| template<>
| struct Derived<char, int> : Base<int> {
|    typedef BASE_ITER (Base<int>) Iterator;       // line20
| };
| 
| // test.cc:20: error: using `typename' outside of template
| --------------------snip---------------------
| 
| 
| ---
| ciaoTJ
| 

-- 
                                                       Gabriel Dos Reis 
                                           gdr@integrable-solutions.net



More information about the Gcc-bugs mailing list