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,036 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: c++11 containers, begin , end and in   
   21 Mar 12 09:27:07   
   
   From: daniel.kruegler@googlemail.com   
      
   Am 21.03.2012 06:42, schrieb MM:   
   > Considering all the containers in the std library: array, forward_list,   
   > list, dequeue, vector, set, multiset, map, multimap, unordered_set,   
   > unordered_multiset, unordered_map and unordered_multimap, queue,   
   > priority_queue and stack, and their iterator types,   
   >   
   > What is the behaviour required from decrementing an iterator that =   
   > begin(), and incrementing a iterator = end() ?   
      
   There is no container where this operation is defined. The reason for   
   this can be split in two cases:   
      
   1) forward_list defines a special iterator value returned from   
   before_begin() which has the property that incrementing it returns the   
   same value as begin(). But the standard specifies this container to   
   support forward iterators, which means that the standard does not define   
   what happens when you try to decrement an iterator of this container   
   type. You should expect that the compiler rejects you code.   
      
   2) All other containers do not define any iterator value before begin(),   
   which indirectly means that attempting to form such a value (e.g. by   
   decrementing a begin() iterator brings you immediately into   
   undefined-behaviour-land and you wont get your $200 salary ;-). Here we   
   don't need to consider forward iterator values (like those from the   
   unordered containers) as a special case.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ 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