Tuesday, August 16, 2011

C++11 Feature Availability Spreadsheet Updated

Now that C++ and Beyond 2011 is behind me, C++0x has been officially christened C++11 (or, as I like to think of it, "C++:  The Spinal Tap Edition"), and Stephan T. Lavavej pointed me to his unbelievably easy to download and install binary of gcc 4.6 for Windows, I had time to play with gcc 4.6 and update my C++11 feature availability summary (now rechristened to reflect that "C++0x" is terminologically pass√©).  Once again I found myself cackling with glee as I successfully built and ran programs with wacky stuff like
constexpr int factorial(int n) noexcept {                 // define constexpr function!
  return (n == 1) ? 1 : (n * factorial(n-1));

std::array<int, factorial(5)> a;                          // use it!
for (auto i : { 1, 2, 3, 4, 5} ) std::cout << i << " ";   // range-based for!
I mean, really, who can't love that?   More complicated stuff works, too, like defaulting and deleting and automatically generating move operations.  And nullptr (already present in VC10) joins the party, too. Fun, fun, fun. 

Because C++11 is no longer a draft standard (even if there are still some bureaucratic levers to be moved) and compiler support for C++11 is increasingly common, there's no need for me to keep updating the feature availability summary, so, modulo bugs in the existing data (I'll fix those as they're brought to my attention), I'm freezing it as is.  That will give me more time to play around with the newly-minted and schnazzed up C++, and that's a lot more rewarding than putting little letters in boxes on a spreadsheet.

Have fun with C++11.  How can you not?



ikalnitsky said...

auto, lambda and range-based for-loop is awesome! This is a big step in usability side.

John-Philip Johansson said...

Time for Even More Effective C++? :D

Scott Meyers said...

Let's just say you're not the first to have suggested something like this :-)


Anonymous said...

Update of More Effective C++ - I'll toss my vote in for what it's worth.

Anonymous said...

Mr. Meyers, I read your books about C++ and they are the best books I've read about programming ever.

I especially don't like it when I grab a 1,000 page book about C++ hoping it is useful to me and then notice that it's full of beginner-level blah blah "this is how you will output text to the console" crap. I've noticed that libraries mostly have these kinds of books which serve no real purpose for someone who has some level of understanding of the language already. Then the really advanced books are a bit too complicated, or dare I say, boring! Or even containing a lot of information which is not actually useful when you want to create a program (so it's more like for compiler writers). Your books were not boring but they did clearly go beyond the usual beginner-level books. Thanks.

NoName said...

To someone who has not yet read "Effective C++", would you suggest to buy the 2005 edition, or wait a little for the next one?

Scott Meyers said...

@NoName: I have not yet started work on a new edition of Effective C++ (or in fact any of my books), so I suggest you buy the current edition. For my perspective on the content of that book in a C++11 world, I suggest you consult the special forward I wrote for it.

Thanks for your interest.