Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14
-
None
Description
QKeyValueIterator<K&,V&> defines some STL-compatibility nested typedefs:
using value_type = std::pair<K&,V&>; using reference = const value_type &;
QKeyValueIterator::operator* return type is value_type.
std::reverse_iterator::operator* return type is reference.
Therefore, if a QKeyValueIterator is wrapped in a reverse_iterator, then reverse_iterator::operator* will return a dangling reference to the temporary object returned by QKeyValueIterator::operator*.
A possible solution would be to change the definition of reference:
using reference = value_type;
This would be consistent with the STL principle that the reference typedef doesn't actually need to be a reference type, if it is a proxy type that can behave like a reference.