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,912 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: Passing pointer to member objects   
   11 Mar 13 01:42:27   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2013-03-11 00:23, Daniel Krügler wrote:   
   > I assume that your compiler accepts *some* parts of boost. In this   
   > case give a try to   
   >   
   > #include "boost/type_traits/is_convertible.hpp"   
   > #include "boost/type_traits/decay.hpp"   
   > #include "boost/utility/enable_if.hpp"   
   >   
   > template   
   > typename boost::enable_if<   
   >   boost::is_convertible::type, U>,   
   > R>::type   
   > get(R* begin, R* end, V R::* m, U v)   
   > {   
   >     for(R* it=begin;it!=end;it++)   
   >       if((*it).*m == v)   
   >         return (*it);   
   >     return R();   
   > }   
      
   I should add that with this signature you would cover all currently   
   mentioned overloads. It includes your original case and the   
   array-cases that I presented above (but not repeated in this reply).   
      
   > [..], or you make a little be less generic, such as giving up the   
   > "convertible-to" relation:   
      
   Oops, that was supposed to mean:   
      
   "or you make it a little bit less generic, such as giving up the   
   "convertible-to" relation:"   
      
   I apologize for the typo,   
      
   Daniel Krügler   
      
      
      
   --   
         [ 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