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,435 of 33,346   
   Marc to Johannes Schaub   
   Re: extern "C" template   
   31 Aug 11 14:49:36   
   
   From: marc.glisse@gmail.com   
      
   Johannes Schaub  wrote:   
      
   > It is not possible to directly specify a function type with C language   
   > linkage in C++11. But in the Bloomington meeting, it was deemed useful to   
   > have 'extern "C"' linkage for alias templates possible. You can do the above   
   >   
   > as follows then:   
   >   
   >   extern "C" {   
   >     template   
   >     using FCT = R(P...);   
   >   }   
   >   
   > And formulate the function type nested in the function pointer type as   
   > follows   
   >   
   >  struct A {   
   >     // note: T is still deducible   
   >     template   
   >     A(FCT *f) { f(); }   
   >  };   
      
   I thought about that, Jonathan Wakely suggested it too, but I was   
   somehow convinced that a template alias always implied that deduction   
   would fail. Now I've thought some more about what it means, and it   
   makes perfect sense, this is a very natural solution, extending the   
   one with a typedef for the non-template case (ideally one wouldn't   
   need an alias at all).   
      
   Thanks for teaching me that template aliases have extra use that a   
   typedef inside a template class doesn't have.   
      
      
   --   
         [ 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