I have worked around the problem.  The HashTable methods now have __GCC__ code 
that detects when the object has not had its constructor called, and
Performs the same initialization on-demand.

>From the lack of responses indicating otherwise, I suppose I will assume this 
>is a bug in G++.  Should that go into bugzilla?

                                                            
Dr. Michael J. Gourlay
University of Central Florida / FIEA

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Gourlay
Sent: Thursday, March 16, 2006 4:33 PM
To: gcc-bugs@gcc.gnu.org
Subject: too few template-parameter-lists with nested template


I've seen other posts asking a similar question, but the solution continues to 
evade me.

I have a line of code that compiles and runs as designed with MSVC but not 
under g++ 3.4.2 (mingw-special):

HashTable<Factory<AbstractProductUnitTest>::FactoryEntry> 
Factory<AbstractProductUnitTest>::sFactoryTable ;

The following lines do compile (but see caveat below):

template <class EntryT> class 
HashTable<Factory<AbstractProductUnitTest>::FactoryEntry> 
Factory<AbstractProductUnitTest>::sFactoryTable ;

...or...

template <> class HashTable<Factory<AbstractProductUnitTest>::FactoryEntry> 
Factory<AbstractProductUnitTest>::sFactoryTable ;


The resulting code, however, seems not to have called the constructor on 
sFactoryTable by the time it gets used, which is well after "main" starts - 
i.e. this is not a problem with order of execution of static constructors.


Here is some context for the code above:

template <class EntryT> class HashTable
{
      ...
    protected:
        LinkedList<EntryT> * mLists ;
      ...
} ;

template <class AbstractProductT> class Factory : public HashEntry
{
      ...
    protected:
        struct FactoryEntry : public HashEntry
        {   // struct to associate a factory with a hash table key.
            Factory<AbstractProductT> * mFactory ;
        } ;
        static HashTable<FactoryEntry> sFactoryTable ;  // singleton list of 
concrete factories associated with this abstract factory
} ;

I searched http://gcc.gnu.org/ and found several simpler variations where 
people complained about initialization of static templated class members, the 
solution to which was to prefix the class name with "template <>", but I found 
no mention of a situation like that above, which involves nested templated 
classes.

I apologize if this reflects my ignorance rather than a bug in the GNU C 
compiler, and would appreciate having somebody explain how to make this work.

Thanks.

                                                            
Michael J. Gourlay

Reply via email to