What C++0x feature will have the most impact? [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this questionWhat will day to day C++ development be like in a few years? What C++0x features will change C++ development the most?
In what order should I concentrate learning these new features?
I personaly think that move semantics (and rvalue references in general) are the most important change, on par with threads/locks/atomics. Everything else is, more or less, simplification of syntax or standardization of common third-party solutions -- we can write functors when we need lambdas and we have numerous regex libraries. Even for the lack of atomic operations there were some solutions, but there were NO move constructors/move assignment operators.
Being able to move objects changes the whole perception of the language to me. Even though we had RVO and the swap-to-temporary trick to emulate some of it already, it's hard to imagine how the life changes when this is part of everyday life. It's not just ofstream("log.txt") << "Hi!";
, or the so much faster STL algorithms, it's a whole new way of passing data between functions.
auto because people will overuse it.
Lambdas, because they finally introduce reasonable means of harnessing the benefits of functional programming.
Range-based for-loops.
for (int x: numbers) std::cout << x << " ";
Yay!
Unicode support. No more cobbles and hacks to get correct handling of unicode characters -- now the entire unicode standard is natively supported by the language.
auto
, lambdas, and smart pointers.
Standard facilities for threading and synchronization.
Regular expressions as a standard library - you know you need them.
We switched to 2010 about a month ago. The two most common things we've used are auto and lambda. Rvalue references have allowed me to do many things that were not possible before, but in day-to-day use they are not AS used as lambda and auto.
this is a great article about new features Explicating the new C++ standard (C++0x), and its implementation in VC10
The auto keyword For automatic data-type deduction (at compile time), depending on initialization.
The decltype keyword For deducing data-type from expression, or an auto variable
The nullptr keyword Null pointer is now promoted, and is been awarded a keyword!
The static_assert keyword For compile time assertions. Useful for templates, and validations that cannot be done using #ifdef.
Lambda Expressions Locally defined functions. Inherits features from function-pointers and class objects (functors).
Trailing Return types Mainly useful when templated function's return type cannot be expressed.
R-value references Move semantics - resource utilization before temporary object gets destroyed.
there are also described new features of Microsoft's new compiler
auto in the for loops, and lambdas for the algorithm, I'll start a massive using of for_each.
Concepts. At last, we'll be able to type-check templates before instantiating them, and when we instantiate them incorrectly, we'll get sensible error messages. Whoops! The C++0X committee couldn't agree and eventually tossed them out. Ah well, wait for C++1X...
精彩评论