Re[8]: Оцените код
От: noodles  
Дата: 09.09.08 09:56
Оценка:
N>>The C++ Programming Language, Third Edition, Bjarne Stroustrup. Упоминается такое в паре мест.

СМ>ты бы цитату привел, Старуструп большой


Стр.92

"Taking a pointer to the element one beyond the end of an array is guaranteed to work. This is
important for many algorithms (§2.7.2, §18.3). However, since such a pointer does not in fact point
to an element of the array, it may not be used for reading or writing. The result of taking the
address of the element before the initial element is undefined and should be avoided. On some
machine architectures, arrays are often allocated on machine addressing boundaries, so ‘‘one before
the initial element’’ simply doesn’t make sense."

Интересно, что это учитывается в реализации обратных итераторов reverse_iterator<Iter>, стр.557.

СМ>это нельзя a[-1]; но по тексту неясно как псе это описано. так что выводы делать рано


Согласен. Делать выводы по тому куску кода скорополительно. Признаю. Но проверять нужно.
... << RSDN@Home 1.1.4 stable SR1 rev. 568>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.