home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 31,730 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to kelvSYC   
   Re: Inner class as a template parameter    
   09 Dec 11 09:27:06   
   
   658d6935   
   From: daniel.kruegler@googlemail.com   
      
   On 2011-12-09 06:56, kelvSYC wrote:   
   > Is it possible to have an inner class be a template parameter to its   
   > outer class?   
      
   I don't think so.   
      
   > For example, suppose we have:   
   >   
   > template   
   > class Foo;   
      
   Without having a definition available for Foo, the following attempt to   
   use some instance of Foo as a base class must be invalid anyway. So,   
   lets assume we had   
      
   template   
   class Foo {};   
      
   instead.   
      
   > class Bar1 : Foo  {    // Also, can we use Bar2 instead of   
   > Bar1::Bar2?   
   >   class Bar2;   
   > };   
   >   
   > Is the declaration of Bar1 legal as-is, illegal outright, or needs   
   > forward declarations?   
      
   I don't see how the language can support this. E.g. 3.3.2 p5   
      
   "After the point of declaration of a class member, the member name can   
   be looked up in the scope of its class."   
      
   does not mention this. Further, the extension rules in 3.3.7 p1 do not   
   apply either. It is not possible to forward declare members of a class   
   that has not yet been started to be defined.   
      
   > If the last of these three, what declarations do we need?   
      
   As shown above this is not possible as written. Maybe you could explain   
   a bit what you *actually* want to realize with Bar1::Bar2 within Foo?   
   Depending on that, different approaches could solve the problem.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca