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,294 of 33,346   
   Piotr Nycz to All   
   Re: Which one(s) of the following std::v   
   12 Mar 14 11:32:31   
   
   From: piotrwn1@googlemail.com   
      
   W dniu poniedziałek, 10 marca 2014 08:10:02 UTC+1 użytkownik g   
   odb...@googlemail.com napisał:   
   > For C++11, I have 4 member functions in question:   
   >   
   >    vector& operator=(const vector& x);   
   >    vector& operator=(vector&& x);   
   >    vector& operator=(initializer_list);   
   >    void clear() noexcept;   
   >   
   You forget about swap() function. The only way I know to reduce vector   
   capcity is to swap with empty vector:   
      
   vector v(30);   
   assert(v.capacity()>=30);   
   vector().swap(v);   
   assert(v.capacity() == vector().capacity());   
      
   BR,   
   Piotr   
      
      
   --   
         [ 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