[Development] RFC: more liberal 'auto' rules?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Tue Dec 8 10:54:00 CET 2015


Il 08/12/2015 10:46, Ziller Eike ha scritto:
> I really wonder though, why it is possible to assign the wrong type to a_reference_  here, even if it is const ?
> I cannot do that with e.g. a std::vector (std::vector<const std::string> v; const std::vector<std::string> &v2 = v;), so is that some funny thing with std::pair?

Just that std::pair has a constructor performing implicit conversions 
from another pair's types, see the constructors 4/5

> http://en.cppreference.com/w/cpp/utility/pair/pair

Those conversions silently succeed and kaboom, you're deep copying 
std::strings...

Cheers,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4068 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20151208/32cd842c/attachment.bin>


More information about the Development mailing list