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,606 of 33,346   
   Dave Abrahams to All   
   Re: Storing noncopyable but movable obje   
   03 Nov 11 11:14:49   
   
   From: dave@boostpro.com   
      
   on Wed Nov 02 2011, "Nevin \":-]\" Liber"  wrote:   
      
   > In article ,   
   >  Daniel Krügler  wrote:   
   >   
   >> There exists a fundamental   
   >> requirement, that the wrapped functor is CopyConstructible.   
   >   
   > While this is a requirement of std::function, is it forced by the   
   > implementation?   
      
   No, it's forced by the design.   
      
   > If all one does is moves, couldn't the requirement for the underlying   
   > functor to be Moveable (say, in some future version of the standard)?   
      
   Not without allowing copies to compile.  The best you could do is to make   
   std::function's copy ctor throw an exception if the stored object is   
   move-only, but I'm not sure that's desirable.   
      
   At the point where the std::function is initialized, there's no   
   knowledge of whether it will eventually be copied or moved.  At the   
   point where the std::function is copied or moved, there's no knowledge   
   of the stored callable type.  Therefore, the compiler needs to generate   
   the implementation of std::function's copy constructor at its point of   
   initialization.   
      
   --   
   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