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,387 of 33,346   
   Martin B. to P. Areias   
   Re: Again indices, iterators and syntax    
   28 Jul 11 08:11:52   
   
   94a20989   
   From: 0xCDCDCDCD@gmx.at   
      
   On 28.07.2011 01:08, P. Areias wrote:   
   >   
   > I am implementing some data structures in C++ and thought that some   
   > member functions and operators in the Standard Library are not   
   > necessary.   
   >   
   > For example, when do the std::vector size(), max_size(), capacity(),   
   > empty(), pop_back() and push_back(...) member functions are needed? Or   
   > even convenient?   
   > (...)   
   >   
      
   In my book:   
      
   * The more often a construct is used, the more concise, simple and clear   
   it should be.   
   * If an API is used a lot, it makes a lot sense to have "redundant"   
   elements to the API itself, even if they aren't strictly needed. (This   
   does not mean they have to be class member functions in C++, free   
   functions can also be part of the API of a class and indeed I would   
   consider the  function somehow part of the API of all std   
   library containers.)   
      
      
   > For example, the "push_back" would simply be:   
   >   
   > Vector  v;   
   > v.insert(v.finish(),value);   
   >   
   > (...)   
      
   1st) Well you *can* use push_back *generically* on a vector AND on any   
   other container (list) that supports it.   
      
   2nd) See above. `push_back` is used a lot: Therefore, even if   
   `v.insert(v.finish()` would work generically, for something used as   
   often as push_back, it makes sense to have something named push_back,   
   *inside* the std library API.   
      
   cheers,   
   Martin   
      
   --   
   Stop Software Patents   
   http://petition.stopsoftwarepatents.eu/841006602158/   
   http://www.ffii.org/   
      
      
         [ 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