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 32,053 of 33,346   
   Marc to All   
   moving forward iterators   
   26 Mar 12 10:24:20   
   
   From: marc.glisse@gmail.com   
      
   Hello,   
      
   in C++11, forward iterators may, when dereferenced, yield an rvalue   
   reference. However, the standard describes them as suitable for   
   multi-pass algorithms, and I am wondering how safe that is.   
      
   In 25.1p8 and p9, it says that (Binary)Predicate can't apply   
   non-constant functions to a dereferenced iterator. So if I provide a   
   function object that takes advantage of rvalue-references when it gets   
   them, it is my fault that the algorithm will fail (can be surprising).   
   However that wording doesn't seem to cover operator< and operator==   
   themselves, only explicitly provided comparators.   
      
   For some context, yes it can make sense to have an operator< that eats   
   its rvalue arguments, and for the last use of the elements in a   
   container (say the last thing we care about is the index of some   
   element), we'd like to pass a move_iterator to the algorithm, and let   
   the algorithm decide by itself when it can take advantage of rvalue   
   references (won't need that element again) and when it cannot.   
      
   Does someone have a clearer picture about moving iterators?   
      
      
   --   
         [ 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