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 32,497 of 33,346    |
|    Kaba to goran.pusic@gmail.com    |
|    Re: Why doesn't push_back return an iter    |
|    24 Jul 12 11:51:48    |
      From: kaba@nowhere.com              23.7.2012 22:16, goran.pusic@gmail.com wrote:       > On Monday, July 23, 2012 4:15:18 AM UTC+2, Kaba wrote:       >> Hi,       >>       >> A small but annoying piece of STL is that the push_back and       >> push_front member functions of std::list (say) do not return an       >> iterator to the created element. This results in having to do       >> something like       >       > Hmmm, OK, but the alternative is returning an object from the method.       > If that object isn't used often enough, that's a waste. OTOH, if you       > need this often enough, you could make it into a function, I guess.              First, in my opinion, such micro-optimizations should not in general       hinder the design of usable interfaces (although in general time- and       space-complexity must be considered in design). Second, my intuition       says that the returned iterator will be optimized away by the compiler       anyway. Perhaps someone can correct if my intuition is wrong. I tried to       see it myself from the generated assembler code for this..              #include |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca