Comment 4 for bug 1005955

Revision history for this message
Borim (borim) wrote :

In my oppinion the "new" for loop style, initializer lists, static_assert will surely help everyone. Especially the for loop, whenever I am confronted with some kind of the different lists in widelands, I have to search for the correct iterator macro. The most time I use them, it is some kind of try and error...

With the auto variables I do not know if it does more good or bad. For sure it is tempting to write "for(auto x : queue)". It is so nicely short, and I am a lazy guy ;) But auto variables are a little unclear. What type is x? If queue was not defined near the loop, you have to find it anywhere upwards, or in some header file.
Writing "for(WareId x : queue)" is not much longer, but more precise. I think this will help everyone, who gets in touch with some code the first time, or when you meet you own code after some time.

IMHO If the new c++11 feature will be used in widelands, we should think about which feature should be used and control this with the codecheck utility. Or I will for sure be the first one, who use auto variables ;)

After I read the artikle linked in #3, the use of c++11 should be limited to some specific features, as for example initializer list are not supported by VC.

What do you think about using a subset of the c++11 features?