C++ Truths

cpptruths.blogspot.com · Personal blog · on HN since 2012

Technical blog on C++ covering lambdas, templates, metaprogramming, constexpr, and type system features like variant and variance.

What HN saysHN commenters praise its C++14 lambda series and cite it for constexpr and the Turing-completeness of templates.
17HN people shared it
9linked it in comments
11stories submitted
54story points
8 years agolast shared
2012people per year2026

Most-shared posts

  1. 1
    Inheritance vs. std::variant in C++
    2 people · 2 points · first shared 2018 · discussion on HN
  2. 2
    Covariance and Contravariance in C++ Standard Library
    1 people · 36 points · first shared 2015 · 4 comments on HN
  3. 3
    Fun with Lambdas: C++14 Style
    1 people · 4 points · first shared 2016 · 1 comments on HN
  4. 4
    Fun with Lambdas: C++14 Style (part 2)
    1 people · 3 points · first shared 2014 · discussion on HN
  5. 5
    Using The Pigeonhole Principle in C++ Metaprogramming
    1 people · 2 points · first shared 2014 · discussion on HN
  6. 6
    Dependently-typed Curried printf
    1 people · 2 points · first shared 2016 · discussion on HN
  7. 7
    Fun with Lambdas: C++14 Style (Part 4)
    1 people · 2 points · first shared 2015 · discussion on HN
  8. 8
    Functional programming first principles in C++14
    1 people · 1 points · first shared 2014 · discussion on HN
  9. 9
  10. 10
    C++ Truths: Fun with Lambdas: C++14 Style (part 3)
    1 people · 1 points · first shared 2014 · discussion on HN
  11. 11
    Rvalue references in constructor when
    1 people · first shared 2012
  12. 12
    Creating recursive lambdas and
    1 people · first shared 2014
  13. 13
    C templates are turing complete
    1 people · first shared 2012
  14. 14
    Want speed use constexpr meta
    1 people · first shared 2013
  15. 15
    Why we need compile time reflection in
    1 people · first shared 2014

What HN people wrote when they linked it

kruhft · 2013-05-17
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.htm… 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.
pyrois · 2014-10-02
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-reflect…
pjc50 · 2016-05-17
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-complet… 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.
amelius · 2014-11-14
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.ht…
zem · 2012-11-28
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
vinayan3 · 2012-05-08
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.… 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.

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close