Technical blog on C++ covering lambdas, templates, metaprogramming, constexpr, and type system features like variant and variance.
HN commenters praise its C++14 lambda series and cite it for constexpr and the Turing-completeness of templates.
It's very heartening to see Microsoft and Intel actually adopting the new C++ standards given the fiasco that compiler support for C and C++ standards has been in the past.
That said, I sort of worry about the new approach to C++ standards. It was nearly a decade between C++03 and C++11 (duh) and C++03 was a very minor set of changes compared to C++98. Now we are planning to have major changes every six years, with a minor release in between? That's a new standard every three years. It seems hard to imagine how the compiler developers are going to keep up with that, much less our libraries.
Considering the C++ world is already very fragmented in terms of style and features used (C with Classes, Modern C++, horrible in-between?), I don't know if C++17 is going to be good for the ecosystem. I mean, people are talking about adding everything from monads[0] to compile-time reflection[1].
If the designers were willing or able to remove features (do we really need two different initialization syntaxes?) then I would be less concerned, but intentionally breaking every existing C++ library would probably do more harm than good.
Overall, I'm just not sure that this aggressive schedule of adding new features to a large language is a great idea.
[0] http://bartoszmilewski.com/2014/02/26/c17-i-see-a-monad-in-your-future/
[1] http://cpptruths.blogspot.com/2014/03/why-we-need-compile-time-reflection-in.html
Here is a personal anecdote.
I recently tried to make a lambda function in C++ call itself.
My first approach didn't work, because the variables were captured by reference, causing my program to crash (the enclosing scope had disappeared when my recursive lambda function was called). I easily tracked down that problem. But this generated a second problem: without using "capturing by reference", I couldn't make the lambda function refer to itself!
Of course, I looked around on the internet, and I found [1], which actually shows the insane amount of hacking required to make a lambda function call itself. And in the end, this solution didn't even work for me.
So, concluding, I think we're a long way from "functional programming in C++".
[1] http://cpptruths.blogspot.nl/2013/10/creating-recursive-lambdas-and.html
I agree. It depends on what subset of C and C++ is used. If macros are used the only way to actually verify the code will be to pre-process it. Worse is if templates are used. Some templates don't even finish compiling.
http://cpptruths.blogspot.com/2005/11/c-templates-are-turing-complete.html
Most likely no one will write such a template in a mission critical system. However, from a formal verification standpoint the only way to verify the code is to check the binaries.
This is my first exposure to constexpr and it looks very interesting. According to this article it's a second C++ metaprogramming language: http://cpptruths.blogspot.ca/2011/07/want-speed-use-constexpr-meta.html.
The more I learn about C++11 the more I like it. There's some really amazing new features that I've only seen in Lisps, plus there's full static typing, which is the one thing I miss from Lisps.
C++ templates are also turing complete, executed at compile time, and can result in extremely high compile times: http://cpptruths.blogspot.co.uk/2005/11/c-templates-are-turing-complete.html
I don't think that failure to terminate compiles is too big a problem in practice; treat it as just another form of compile-time error and fix your program.
wow, did not know about -Weffc++. quite impressive that they added that flag. here's a blog post if anyone else wants to read about it:
http://cpptruths.blogspot.com/2006/08/g-compiler-option-weffc.html