C
C++Next
cpp-next.com · Group blog · on HN since 2009
C++Next is a blog on modern C++ techniques, including performance, expression templates, concepts, and lessons from Elements of Programming.
What HN saysHN commenters link it most often for its pass-by-value article on copy elision and speed, and for its series on Elements of Programming.
21HN people shared it
6linked it in comments
18stories submitted
86story points
12 years agolast shared
2009people per year2026
Most-shared posts
- 1Want speed? Pass by value.6 people · 35 points · first shared 2009 · 30 comments on HN
- 2Having it all: Pythy syntax for C++3 people · 6 points · first shared 2011 · discussion on HN
- 3Expressive C++: Expression Optimization2 people · 4 points · first shared 2011 · discussion on HN
- 4A Breakthrough for Concepts in C++2 people · 3 points · first shared 2011 · discussion on HN
- 5C++Next1 people · 20 points · first shared 2009 · 9 comments on HN
- 6Expressive C++: Fun With Function Composition1 people · 5 points · first shared 2010 · discussion on HN
- 7Appearing and Disappearing consts in C++1 people · 3 points · first shared 2011 · discussion on HN
- 8Generic Functions and Function Objects « C++Next1 people · 2 points · first shared 2012 · discussion on HN
- 9Evil, or Just Misunderstood? « C++Next1 people · 2 points · first shared 2012 · discussion on HN
- 10To auto or not to auto?1 people · 2 points · first shared 2010 · discussion on HN
- 11Algebraic Data Types in C++1 people · 2 points · first shared 2012 · discussion on HN
- 12Expressive C++: A Lambda Library in 30 Lines (Part 1 of 2)1 people · 1 points · first shared 2010 · 1 comments on HN
- 13Using strings in C++ template metaprograms1 people · 1 points · first shared 2012 · discussion on HN
- 14%E2%80%9Celements of programming%E2%80%9D study group1 people · first shared 2010
- 15Exceptionally moving1 people · first shared 2011
What HN people wrote when they linked it
alexchamberlain · 2012-01-12
This is slightly off topic, but a good read...
http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
stingraycharles · 2010-11-28
The book "Elements of Programming" is a good read, http://www.elementsofprogramming.com/, although it's a bit theoretical.
While the book isn't free, this blog thoroughly covers the book and the lessons learned from it in a lecture series:
http://cpp-next.com/archive/2009/11/%E2%80%9Celements-of-programming%E…
srean · 2014-05-09
It has not been mentioned in the original post or the comments yet, so here is a working prototype of a similar idea https://github.com/pfultz2/Pythy (for some specific value of working, you will need Clang)
Its birth lies here Having it all: Pythy syntax for C++ [1]. It was a nice read. Unfortunately cpp-next seems to be down right now. Let me try to find it in Google's cache or internet archive.
Here it is https://web.archive.org/web/20130820172127/http://cpp-next.com/archive…
[1] http://cpp-next.com/archive/2011/11/having-it-all-pythy-syntax/
alexkcd · 2012-07-24
All modern C++ compilers support RVO, so there will be no copy given how this function is implemented. If by "safer" you mean "probably faster", then that's not true:
http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
The author's version is more idiomatic modern C++, while your version is something you'd write for a decade old compiler.
shin_lao · 2009-10-18
More information about copy elision here:
http://cpp-next.com/archive/2009/08/want-speed-pass-by-value/
obiterdictum · 2011-10-29
We have just started using some C++11 features, and with new features come new traps and potential complexities, as you'd expect with C++.
A few examples:
1. Implicit lambdas ("[=]") capture "this" pointer for data members, if you capture a shared pointer and let the lambda object leave the scope, the shared pointer won't be copied (http://stackoverflow.com/q/7764564/23643), which may create unpleasant results, like code blowing up in your face.
2. Overuse of "auto" (not exclusive to C++) may make the code harder to read, especially if storing a result returned from a function. You can't tell if the return value is a smart pointer or a raw pointer, value or a reference, so you can't figure ownership semantics just by looking at the local code.
3. Move constructors/assignment operators are a bit of a black magic, especially with regard to suppressing default implementation (http://mmocny.wordpress.com/2010/12/09/implicit-move-wont-go) and exception safety (http://cpp-next.com/archive/2009/10/exceptionally-moving). I would refrain from using it, until I fully understand it.
With that said, most of C++11 is a welcome change and makes C++ more pleasant to write, but, as always, you have to have your guard up and use new features judiciously.