c++/10307: constructor for static object of template omitted

Wolfgang Bangerth bangerth@ices.utexas.edu
Fri Apr 4 20:26:00 GMT 2003


The following reply was made to PR c++/10307; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ices.utexas.edu>
To: Douglas Kilpatrick <kilpatds@oppositelock.org>
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: c++/10307: constructor for static object of template omitted
Date: Fri, 4 Apr 2003 14:17:24 -0600 (CST)

 > I would have though that a subclass of a template by a non-template would
 > cause the template to be instantiated, but it doesn't seem to.  I have to
 > declare an explicit variable of the non-template class to get things to
 > work.
 
 Well, each component of a template can be instantiated in two ways:
 - an explicit instantiation
 - implicit instantiation by using this part (i.e. using a template member 
   function, etc)
 Note that in implicit instantiation, using one part of a template class 
 doesn't imply that _all_ the parts are instantiated. Deriving from a class 
 (and using the derived class) counts as implicit instantiation of the base 
 class.
 
 > What's the syntax for forcing that without actually declaring a variable? 
 > Its not a template, so using the explicit template instantation syntax
 > doesn't work.  (Code freely available if you want it.  ~6k)
 
 Just as I wrote it:
   template int Class<int>::StaticMemberVariable;
 (that's an explicit instantiation), or simply instantiating the entire 
 class and all it's parts:
   template class Class<int>;
 
 W.
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                                www: http://www.ices.utexas.edu/~bangerth/
 
 



More information about the Gcc-prs mailing list