C++0x is here!

C++11 has finally been approved. I've been digging more on C++ lately and I think that although it is a very complex language (or as in Effective C++ says, a set of different languages (C with objects, Templates, preprocessor..)).

This new standard come with many nice features.. but makes the language more complex. Its not a language for everybody nor for everything. But I think that if you want to be efficient you can go the painstaking way with C (which I did on onion), or easier with C++.

These are the features I like the most from C++0x:

  1. Auto_ptr in tr1. We already had it in boost, but having it there will make it more accessible. Only if it were less verbose... (std::shared_ptr<MyObject*> obj). Just now its is a pain to have a method that uses them, but I guess we will have to get really used to it.
  2. rvalues references. Although on the most powerful side (return cedes the object) this was already made by compilers transparently, now with the new "move" semantics it is more explicit and so people will be more aware and force code to use it. I think this is going to be a huge performance boost.
  3. Lambda. Lambda! Finally! now we can set mini functions in place, no need for external C type functions (or boost::bind). And they can use some local variables from caller.. so nice!
  4. Range for AKA foreach. They have a new syntax, not based on Qt's nor Boost's, but finally they are here.
  5. Unicode. Unicode straight into the language ala Python (u"Alò")

There are many more features. Check the Wikipedia article.

These are my favourites, as far as I know them, but sure that with time we will discover more ways to use the new features. Now just waiting for a nice book with all the new language features perfectly explained. Maybe an Effective C++11?

Oh, and full support in GCC, as its not complete yet, although the most important things are here. Or LLVM.

As a side note: will ever Qt be more C++'ish and less C'ish?

1 comment: