Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Index constructor from Vector now explicit
Index constructor from Vector now explicit [message #39196] Tue, 26 February 2013 20:02 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Today I have encountered pretty tricky issue:

VectorMap<String, String> h;
const Index<String>& x = h.GetKeys();

This innocent looking code is broken in a very tricky way: GetKeys returns a reference to Vector<String> which is then picked by Index constructor to perform a conversion to Index<String> (in reality, there should have been h.GetIndex() instead...).

Because I have spent some bad amount of time trying to figure out what is happening, I have decided to disallow this conversion path by making Index constructor from Vector explicit. Now this will probably break some code (but not much of it), e.g. in theide, following line is now invalid:

Index<String> x = Split("hello;world", ';');

and has to be rewritten as

Index<String> x(Split("hello;world", ';'));

but I think it is still better to make this issue safer...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HttpRequest added remaining HTTP methods
Next Topic: .ini file parser refactored
Goto Forum:
  


Current Time: Sun May 05 02:00:54 CEST 2024

Total time taken to generate the page: 0.02522 seconds