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 32,529 of 33,346   
   =?windows-1252?Q?Daniel_Kr=FCgler?= to All   
   Re: Is this kind of static polymorphism    
   05 Sep 12 16:50:44   
   
   From: daniel.kruegler@googlemail.com   
      
   Am 06.09.2012 00:02, schrieb DeMarcus:   
   > On 2012-09-05 09:48, Daniel Krügler wrote:   
   >> [2nd attempt after 24 hours]   
      
   [..]   
      
   > It also seems that this elaborated-type-specifier can have the same   
   > name in different cpp files without getting 'multiple definitions'   
   > during linkage (I found the following).   
   >   
   > §3.3.2/6 saying "-for an /elaborated-type-specifier/ of the form   
   > /class-key identifier/ if the /elaborated-type-specifier/ is used in   
   > [..] otherwise, except as a friend declaration, the identifier is   
   > declared in the smallest namespace or block scope that contains the   
   > declaration.   
   >   
   > Is my interpretation of the standard correct if I say that as long as   
   > the template is declared in an unnamed namespace then I can do the   
   > specialization with the same elaborated-type-specifier name as in   
   > another file (more or less the same as with variable names, right)?   
      
   As the wording says: The name of the type is declared in the unnamed   
   namespace. These are required to be unique for different translation   
   units, so if you have only one such variable definition and template   
   specialization definition per translation unit, this is well-defined.   
      
   > Also another question I have is why I can't put the specialized   
   > runTests() function within the unnamed namespace as well?   
      
   The language requires that a specialization needs to be provided in the   
   same namespace as the namespace of the original (primary) template   
   ([temp.expl.spec] p2). In your example, template MyTestFixture is   
   defined in the global namespace, this means any specialization   
      
   template<>   
   void MyTestFixture::runTests();   
      
   needs to be provided in the same (global) namespace as well.   
      
   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