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,054 of 33,346   
   Johannes Schaub to All   
   Explicit template arguments in perfect f   
   26 Mar 12 18:34:36   
   
   From: schaub.johannes@googlemail.com   
      
   I just discussed cases like "Write a perfect forwarding template that   
   calls 'make_shared'" and was told that this is not possible because   
   "make_shared" requires a single explicit argument.   
      
   I would like to spread knowledge that it is possible to write such a   
   perfect forwarder. Given a generic (template) target function "g" and a   
   perfect forwarder "f", we can write   
      
       template   
       auto f(D &&...d) -> decltype(   
                g(std::forward(d)...)   
       ) {   
         return g(std::forward(d)...);   
       }   
      
   Since "E" is the first parameter pack, it receives any explicit template   
   arguments passed to "f". This has been tested and works on GCC and Clang.   
      
      
   --   
         [ 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