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,264 of 33,346   
   Johannes Schaub to All   
   Re: How to convert a typedef to a std::f   
   09 May 12 15:02:11   
   
   a3d66e46   
   From: schaub.johannes@googlemail.com   
      
   Am 09.05.2012 21:27, schrieb Peter:   
   > Hi Folks,   
   >   
   > given this typedef   
   >   
   > typedef bool (*on_hit_test_type)(widget_interactive *, point const*,   
   > bool *);   
   >   
   > and this member definition   
   >   
   > std::function   
   > on_hit_test;   
   >   
   > Is there a way to convert one to the other? (The typedef to the   
   > std::function template argument or the other way round)   
   >   
      
   The "on_hit_test_type" typedef names the type "T*", and the   
   "on_hit_test" variable is of type "std::function", so to express the   
   second using the first, you do   
      
       std::function::type>   
         on_hit_test;   
      
   To express the first using the second, do   
      
       template   
       struct first_arg;   
      
       template   
       struct first_arg<   
         std::function   
       > {   
         typedef T type;   
       };   
      
       typedef first_arg::type *   
         on_hit_test_type;   
      
   Hope this helps.   
      
      
   --   
         [ 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