Jean-Marc Lasgouttes <lasgout...@lyx.org> writes: | Le 23/10/2012 14:27, Lars Gullik Bjønnes a écrit : >> C++11 would make the code look a lot nicer, esp. thru the use of range >> based for, and auto: >> >> std::vector<string>::iterator at = somevec.begin(); >> std::vector<string>::iterator end = someved.end(); >> for (; at != end; ++at) { >> ... >> } >> >> would be replaced with: >> >> for (auto & s: somevec) { >> ... >> } > | We already have a foreach macro that is not to bad, but we do not use | it much: | foreach (string & s, somevec) { | ... | } > | This is admittedly not as nice as real C++11, but if we converted code | to use it, it would be trivial later to switch to the real thing. > | Concerning auto, I am still not sure that I like it.
Liking it took me some 5 seconds. Auto suddenly makes it nice to work with the complex types you get in C++. Imagine: auto func = [](){}; func(); try to figure out what type func really is. Do you care? -- Lgb