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,821 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to kelvSYC   
   Re: Dangling references in a "value tran   
   19 Jan 12 14:56:30   
   
   27e751f8   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-01-18 21:12, kelvSYC wrote:   
   > Suppose I have this wrapper:   
   >   
   > template   
   > class ContainerWrapper {   
   >     Container container;   
   > public:   
   >     typedef Key key_type;   
   > protected:   
   >     virtual const typename Container::key_type&  mapKey(const key_type&   
   > key) = 0;   
   > };   
      
   It is important to realize that the design of Containerwrapper is the cause of   
   the problems in your derived classes and templates. For the moment I assume,   
   that ContainerWrapper is not intended to be specialized, but you should keep   
   this possibility in    
   mind. So:   
      
   a) either don't "imprint" references as return type of Container   
   rapper::mapKey;   
      
   b) or specialize ContainerWrapper for types that don't work well with the   
   reference-based approach;   
      
   c) or introduce a trait that allows to be more flexible when meapping between   
   template parameter Key and the return type of mapKey.   
      
   HTH & Greetings from Bremen,   
      
   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