What's your favorite C++0x feature?

Viewed 3366

As many of us know (and many, many more don't), C++ is currently undergoing final drafting for the next revision of the International Standard, expected to be published in about 2 years. Drafts and papers are currently available from the committee website. All sorts of new features are being added, the biggest being concepts and lambdas. There is a very comprehensive Wikipedia article with many of the new features. GCC 4.3 and later implement some C++0x features.

As far as new features go, I really like type traits (and the appropriate concepts), but my definite leader is variadic templates. Until 0x, long template lists have involved Boost Preprocessor usually, and are very unpleasant to write. This makes things a lot easier and allows C++0x templates to be treated like a perfectly functional language using variadic templates. I've already written some very cool code with them already, and I can't wait to use them more often!

So what features are you most eagerly anticipating?

23 Answers

auto keyword for variable type inferencing

Lambdas and initializer lists.

Also, the changes to make it easier to eventually bring C++ into a garbage collected model, those seem pretty interesting. Perhaps C++1x will actually bring in garbage collection, but 0x/10 just set things up for the eventuality.

I want Rvalues references.

All the other new features are stuff that we could easily live without(alas features). However the lack of Rvalues in C++ so far has caused hundreds of template library authors to have to "hack" around the broken Rvalue ref issue.

Variadic templates! (Which combined with r-value references gives us perfect forwarding!)

Threads and atomics.

With multicore processors now the norm C++0x should have been C++07.

G.

  1. It has to be the incorporation of some of the Boost libraries (shared_ptr<> and bind top the list)

  2. Control over template instatntiation should finally solve the issue of the enormous compile times and make it actually feasible to use modern template code in large projects.

  3. Template typedefs

Lots of other small but important things, but they do matter in production code.

Hands down concepts for me. But initializer lists, lambdas, and variadic templates are a close second.

I can't decide between Null Pointer Type, Tuple Types, or Regex. 'Foreach' is up there too. 'Smart Pointers' goes without saying... :-)

Basically, I'm really looking forward to the update.

Personally I think heavy use of the null pointer type is going to catch a lot of bugs. Tuples are great for dealing with relational data. Lots of cool stuff.

It's not big, but I'm loving the idea of a true nullptr. Should have been a keyword right from the git-go.

unicode, multithreading, hash_tables, smart pointers and regular expressions.

ps : Wonder why they just cant do a gr8 code review and accept all the boost and tr1 libs into the standards and make life easier for everyone. All they would then have to solve is agreeing on a working optional garbage collection model.

The syntax going from bad to worse.

Variadic templates and lambdas are nice, though the syntax of both is unfortunately pretty objectionable.

Smart pointers. It really makes a world of difference not having to explicitly memory-manage heap-allocated objects.

Obviously you still need to "know what you're doing", but in my experience it has decreased the number of memory-related bugs at least one order of magnitude in software I've worked with.

I like constexpr especially in conjunction with variadic templates and user defined literals we can finally have binary literals and lots of other goodies.

obj.bitmask |= 00001010B; 

REGEX!! and parallel programming librarys though I don't know the features of them all yet.

Related