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,973 of 33,346    |
|    =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Gene Bushuyev    |
|    Re: Where are iterators for rvalue conta    |
|    02 Mar 12 12:42:49    |
      178b9c1e       From: daniel.kruegler@googlemail.com              On 2012-03-02 11:41, Gene Bushuyev wrote:       > I was looking at the C++11 standard docs and didn't see iterators for       > rvalue containers.              There exist a general adapter for any forward iterator to a "moving       iterator", namely std::move_iterator.              > For example, std::vector has only these begin()       > member functions:       >       > iterator begin();       > const_iterator begin() const;       >       > Where is "iterator begin()&&;" ?              It does not exist, for good reasons:              1) You cannot overload ref-qualified and non-ref-qualified member       functions, so simply adding begin() &&; would make instantiating vector       for these functions ill-formed.              2) They are not needed, because you can call a non-ref-qualified from an       rvalue.              3) It would not help solving your problem to provide begin()&& returning       an iterator, because the root of your problem is that the iterator's       indirection operator returns an lvalue, but you need one with an rvalue.              > Say, I want to construct my container by moving from a vector,       >       > MyContainer::MyContainer(vector |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca