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,681 of 33,346   
   Dave Abrahams to All   
   Re: How to conditionally disable a copy    
   22 Nov 11 16:38:24   
   
   5b35552d   
   From: dave@boostpro.com   
      
   on Tue Nov 22 2011, Andrzej KrzemieĊ„ski  wrote:   
      
   > Hi,   
   > I am trying to implement a template "wrapper" for any arbitrary type,   
   > much like boost::optional. In fact I am trying to write my own   
   > alternative implementation of optional. I want it to have the   
   > following property: if the wrapped type T ptovides copy constructor,   
   > optional also provides a copy constructor; similarly, optional   
   > provides a move constructor iff T provides one. With concepts (as   
   > defined in N2914), I would express it like this:   
   >   
   >   template< typename T >   
   >   struct Optional   
   >   {   
   > 	  requires CopyConstructible   
   > 	  Optional( Optional const& );   
   >   
   >       requires MoveConstructible   
   > 	  Optional( Optional && );   
   >   };   
   >   
   > Do you know of any way to implement similar behavior in C++11? The   
   > enable_if trick does not seem to work for disabling the default   
   > constructor.   
      
   I think you might need to dispatch to different specializations of the   
   whole class template based on the properties of T.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
         [ 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