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,277 of 33,346   
   Marc to nroberts   
   Re: variadic templates, decltype, sfinae   
   10 May 12 16:22:38   
   
   246e2cd1   
   From: marc.glisse@gmail.com   
      
   nroberts  wrote:   
      
   > So I'm trying to make something sort of like a tuple that is accessed   
   > with a placeholder variable using variadic templates.  I keep getting   
   > an error I do not expect:   
   >   
   >   
   > #include    
   >   
   > template < int I > struct arg {};   
   > template < typename ... Pack> struct thingy;   
   >   
   > template < typename Head, typename ... Tail>   
   > struct thingy : thingy   
   > {   
   >    Head val;   
   >   
   >    thingy(Head && h, Tail&& ... t)   
   >       : thingy(std::forward(t)...), val(h)   
   >     {}   
   >   
   >     template < int I >   
   >     auto get(arg) -> decltype(thingy::get(arg()))   
   >     {   
   >       return thingy::get(arg());   
   >     }   
   >   
   >     Head& get(arg<1>) { return val; }   
   > };   
   > template < > struct thingy<> {};   
      
   This looks a lot like:   
      
   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51501   
      
   You need to find another way to specify the return type of the   
   function, which shouldn't be hard in this case.   
      
      
   --   
         [ 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