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 33,279 of 33,346   
   =?ISO-8859-2?Q?Krzysztof_Czai=F1ski to All   
   auto-generated move assignment and base    
   15 Feb 14 21:37:40   
   
   From: 1czajnik@googlemail.com   
      
   { Please limit your text to fit within 80 columns, preferably around 70,   
     so that readers don't have to scroll horizontally to read each line.   
     This article has been reformatted manually by the moderator. -mod }   
      
   Hello,   
      
   If class B has a base or member of type A with an assignment operator   
   taking A by value, does it implie B's auto-generated move assignment is:   
   - deleted?   
   - defaulted?   
   - not present?   
      
   That is, should this sample print "copy" or "move"?   
      
      
   #include    
      
   struct A   
   {   
       A() = default;   
       A( A const& ) { std::cout << "copy" << std::endl; }   
       A( A&& ) { std::cout << "move" << std::endl; }   
       A& operator=( A ) { return *this; }   
   };   
      
   struct B   
   {   
       A a;   
   };   
      
   int main()   
   {   
       B x, y;   
       x = std::move(y);   
   }   
      
      
   For me it prints "copy" in GCC-4.7, and "move" in MinGW-4.8.   
      
   This question originated from [1], where Adam Wulkiewicz tested a   
   similar sample and from that I expect compilers he used to produce   
   "copy". Those compilers are:   
   GCC4.7, Clang3.2, MinGW 4.7, VS2010, VS2013   
      
   Regards,   
   Kris   
      
   [1] http://boost.2283326.n4.nabble.com/move-interest-the-pass-by   
   value-and-swap-idiom-and-explicit-copy-constructors-td4659419.html   
      
      
   --   
         [ 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