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,482 of 33,346   
   Seungbeom Kim to Wil Evers   
   Re: Layered data structures   
   16 Jul 12 06:26:16   
   
   From: musiphil@bawi.org   
      
   On 2012-07-15 16:05, Wil Evers wrote:   
   >   
   > I think the key is to make sure the A instance is closed for   
   > modification before it is shared.  The following class template is my   
   > take at expressing that:   
   >   
   >     template    
   >     class shared_immutable_ptr {   
   >   
   >     public :   
   >         template    
   >         shared_immutable_ptr(std::unique_ptr consumed)   
   >         : instance(std::move(consumed))   
   >         { }   
      
   Since you cannot copy std::unique_ptr, you need a reference parameter.   
      
   >   
   >         const T *operator->() const   
   >         { return instance.operator->(); }   
   >   
   >         const T& operator*() const   
   >         { return *instance; }   
   >   
   >         // etc...   
   >   
   >     private :   
   >         std::shared_ptr instance;   
   >     };   
      
   How is shared_immutable_ptr different from std::shared_ptr?   
      
   --   
   Seungbeom Kim   
      
      
         [ 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