I read the documentation for C ++ list iterators, but couldn't figure out what it is: Are C ++ iterators "safe"? I mean, does it stop growing as soon as it reaches the last existing item in the list?
[] 's
No, they are not “safe” in that sense. You can increase the iterator to the end. For all iterators in the standard library, this will lead to undefined behavior. You could define your own iterators that will behave in a safe way if you want.
, , std::list::iterator. - , . , , . , .
std::list::iterator
, , , .. . :
std::list
erase()
std::remove()
, , , .
, it != list.end(), , .
it != list.end()
. " ", Undefined Behavior.
. ++, .
, , .
, "", , .
- . , , , . std (. Std:: copy (first_in, last_in, first_out, last_out) , , (, )
- , , . , ++, operator-- . , contianer . . - Iterator, Iterator Proxy
Use correctly, iterators are very useful.Therefore, the question “C ++ Iterators are Safe” will depend on how it is used.Please note: misuse of the printf API can lead to serious errors. The implementation will be safe to use or not.
Source: https://habr.com/ru/post/1788039/More articles:SQL - using IN over tables joined in several rows - sqlException handling for Windows mobile devices - windows-mobileCatch "302 Found" when using the GWT RequestBuilder - httpAndroid + MySQL using com.mysql.jdbc.Driver - javaInfragistics UltraTree с флажками в выбранных ячейках - c#Configuring the contents of an Inset in a UITableView after returning from another topic - multithreadingHide iframe by default - javascriptSQL Server 2008 - Full Text Search - sqlКто-нибудь знает рабочий OCR (PHP)? - phpHow to update HTML element using jQuery and Galleria? - javascriptAll Articles