Re[5]: Глюк в STL (vector)
От: Юрий Жмеренецкий ICQ 380412032
Дата: 19.12.08 02:57
Оценка: 62 (3)
Здравствуйте, Кодт, Вы писали:
...
ЮЖ>>Только этот может быть использован, т.к:
ЮЖ>>23.2.4.3/4 (vector::erase)

К>Аха, буду знать.

К>Хотя жаль, конечно: на обменах в некоторых случаях могло бы быть эффективнее.

Скоро будет счастье =)
Assignable переименовали в CopyAssignable, добавили Swappable, Destructible, а так же:

MoveConstructible
T t = rv, ... There is no requirement on the value of rv after the
construction.

MoveAssignable
t = rv, ... There is no requirement on the value of rv after the
construction.


Требования к элементам контейнеров сильно ослабили:

Objects stored in these components shall be MoveConstructible and
MoveAssignable.


+От объектов требуется быть CopyConstructible и/или CopyAssignable в отдельных случаях вроде использования конструктора копирования и 'operator=' контейнера и совсем небольшого набора операций.

+ CopyAssignable от объектов ассоциативных контейнеров не требуется (требуется только для ключей).

+ Возвращаясь к std::vector<T>::erase:

The destructor of T is called the number of times equal to the number of the elements erased, but the
move assignment operator of T is called the number of times equal to the number of elements in the vector after
the erased elements.

+...
это еще на окончательная версия, но в library defect reports прослеживаются некоторые тенденции:

DR#276:
...
Rationale:
list, set, multiset, map, multimap are able to store non-Assignables. However, there is some concern about list<T>: although in general there's no reason for T to be Assignable, some implementations of the member functions operator= and assign do rely on that requirement. The LWG does not want to forbid such implementations.
...
In principle we could also relax the "Assignable" requirement for individual vector member functions, such as push_back. However, the LWG did not see great value in such selective relaxation. Doing so would remove implementors' freedom to implement vector::push_back in terms of vector::insert.



Swappable requirements в первоначальном варианте выражались в виде:

T is Swappable if T satisfies the CopyConstructible requirements (Table 33) and the CopyAssignable requirements...


Позже поменяли:

DR#672
...
Proposed resolution:
Change 20.1.1:

T is Swappable if T satisfies the MoveConstructible requirements (Table 34 ) and the MoveAssignable requirements.
...
[ Kona (2007): We like the change to the Swappable requirements to use move semantics...]

 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.