Unlike std::map and std::hash_map, corresponding versions in Qt do not bother to return a reference. Isn't it quite inefficient, if I build a hash for quite bulky class?
EDIT
especially since there is a separate method value(), which could then return it by value.
The documentation for QMap and QHash specifically say to avoid operator[]
for lookup due to the reason Martin B stated.
If you want a const reference, use const_iterator find ( const Key & key ) const
where you can then use any of:
const Key & key () const
const T & value () const
const T & operator* () const
const T * operator-> () const
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With