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,295 of 33,346   
   goodbyeera@googlemail.com to All   
   Re: Which one(s) of the following std::v   
   13 Mar 14 07:33:31   
   
   { new text reformatted to fit in ~70 characters per line.  quoting   
     left as is to draw the poster's attention to formatting. -mod }   
      
   On Tuesday, March 11, 2014 3:20:01 PM UTC+8, Daniel Krügler wrote:   
   > In C++11 the effects of the move/copy-assignment operators depends on   
   >   
   > the nature of the allocators in source and target. This is specified in   
   >   
   > [container.requirements.general] p8:   
   >   
   >   
   >   
   > "[..] The allocator may be replaced only via assignment or swap().   
   >   
   > Allocator replacement is performed by copy assignment, move assignment,   
   >   
   > or swapping of the allocator only if   
   >   
   >   
   allocator_traits::propagate_on_container_copy_assignment::va   
   lue,   
   >   
   >   
   allocator_traits::propagate_on_container_move_assignment::va   
   lue,   
   >   
   > or allocator_traits::propagate_on_container_swap::value   
   >   
   > is true within the implementation of the corresponding container   
   >   
   > operation. [..]"   
   >   
   >   
   >   
   > The implication of this wording is that if allocator replacement happens   
   >   
   > during copy/move assignment, then the previous storage must be freed   
   >   
   > (and thus the capacity reduced to zero during the operation which   
   >   
   > corresponds to an effective reduction of the capacity). It is IMO not   
   >   
   > really clear from the wording, whether in such a situation an   
   >   
   > implementation is required or allowed to check for allocator equality   
   >   
   > when propagate_on_container_copy/move_assignment return true and to   
   >   
   > finally decide on reallocation depending on the outcome of that test.   
   >   
   >   
      
   Hi Daniel,   
      
   Thank you very much for replying with detailed information.  I think   
   I'm now clear regarding vector::clear() and   
   vector::operator=(initializer_list).   
      
   For copy/move assignment, I now understand that when allocator   
   replacement happens, reallocation and reduction of capacity may well   
   happen.  But what if   
   allocator_traits::propagate_on_container_copy_assignment()/a   
   llocator_traits::propagate_on_container_move_assignment()   
   is false (and in the case of move assignment, the target and source   
   allocator does not compare equal), can we be assured that reduction of   
   capacity won't take place?   
      
   Thanks,   
   Goodbyeera   
      
      
   --   
         [ 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