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,867 of 33,346   
   Seungbeom Kim to Walter Mascarenhas   
   Re: template parameter not used in parti   
   25 Feb 13 13:39:27   
   
   From: musiphil@bawi.org   
      
   On 2013-02-25 12:44, Walter Mascarenhas wrote:   
   > The code below does not compile in g++ 4.7.2: it says   
   > that the template parameter S is not used in Foo's   
   > specialization below. Is g++ correct on this? If so,   
   > how would I specialize the struct Foo for   
   > T = std::vector::iterator in a general way?   
   >   
   >   
   > #include    
   > template    
   > struct Foo   
   > {   
   > };   
   >   
   > template    
   > struct Foo< typename std::vector::iterator >   
   > {   
   > };   
      
   It may not always be possible to determine S, given std::vector::iterator.   
      
   Suppose you have:   
      
   template  struct X { typedef void type; };   
      
   template  struct Foo { typedef T* ptr; };   
   template  struct Foo::type> { typedef S* ptr; };   
      
   template <> struct X { typedef int type; };   
   template <> struct X { typedef int type; };   
      
   Now, suppose you instantiate Foo. Since X::type is int for   
   both S=short and S=long, what should S be in the specialization?   
      
   --   
   Seungbeom Kim   
      
      
         [ 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