andconstexpr 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?
Scott
auto, lambda and range-based for-loop is awesome! This is a big step in usability side.
ReplyDeleteTime for Even More Effective C++? :D
ReplyDeleteLet's just say you're not the first to have suggested something like this :-)
ReplyDeleteScott
Update of More Effective C++ - I'll toss my vote in for what it's worth.
ReplyDeleteMr. Meyers, I read your books about C++ and they are the best books I've read about programming ever.
ReplyDeleteI 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.
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?
ReplyDelete@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.
ReplyDeleteThanks for your interest.
Scott