Titlul: C++ compiler upgrades on infoarena Scris de: Paul-Dan Baltescu din Aprilie 28, 2013, 02:14:28 http://www.infoarena.ro/blog/cpp11
Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Adrian Budau din Aprilie 28, 2013, 02:19:50 Another cool thing:
Cod: struct A { No need for constructors anymore for simple stuff. Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Paunel Cosmin din Aprilie 28, 2013, 02:33:48 Foarte misto, bravo! :D
Pentru al doilea feature se poate si pe set-uri din STL ? Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Paul-Dan Baltescu din Aprilie 28, 2013, 03:11:31 Yes, you can do range-based for loops on any iterable container. That includes sets and maps:
Cod: set<int> s = {5, 4, 3, 2, 1}; Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Laurentiu Ion din Aprilie 28, 2013, 12:05:53 Good stuff.
It's nice that we also have a standard container for constant sized, C-like, arrays: Cod: array<int, 3> arr = {1, 2, 3}; Now introducing tuple<int,double,string,...>, which are like std::pair, but they can contain any number of elements. Yay, no more annoying custom structs or pairs of pairs of pairs gibberish. And then there are hash_map and hash_set, which were previously only available in the ext directory, under __gnu_cxx. Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Adrian Budau din Aprilie 28, 2013, 14:47:17 Another 2 things:
to_string a function which conversts numeric types to std::string and std::tie. WIth std::tie you can do stuff like this Cod: auto a = std::make_tuple(0, "Hello world!", 5.5); And now x and y have the values a.first and a.second. Titlul: Răspuns: C++ compiler upgrades on infoarena Scris de: Petenchea Alexandru din Aprilie 28, 2013, 15:05:08 Era si cazul :P . Multumim ! :D
The g++ 4.8 compiler also has some nice optimizer improvements, most of which are available since g++ 4.7 . Inline functions will be optimized even further if the compiler knows some additional information about function's parameters. Cod: inline int a (int x) For a(-1) the compiler will write just half of the code now. This feature is great if you inline large functions which are called many times. Also non-inline functions are optimized. Cod: void f (bool x) g++ will now produce two copies of f. One with x being true, while other with x being false. This leads to performance improvements previously possible only by inlining all calls. Cloning causes a lot less code size growth. A string length optimization pass has been added since g++ 4.7. It attempts to track string lengths and optimize various standard C string functions ( strlen, strchr, strcpy, strcat, stpcpy and so on...). Cod: void x (char *a, char *b, char *c, char *d) |