News for hackers. Stuff that matters.
Re:Stroustrup on next-gen C++: I didn't want to let go of my... by kybernetyk on Friday December 14, 2012 @05:17AM (#4920289)
We were lucky enough to start a new project ~1 year ago - completely in C++11. We make heavy use of all the new fun C++11 stuff like lambdas, move constructors (yay, no vectors of pointers anymore!) and all that auto/decltype syntactic sugar.

And I must say: It's a whole different programming language and a new level of productivity.

Re:Stroustrup on next-gen C++: I didn't want to let go of my... by forrestthewoods on Friday December 14, 2012 @06:52AM (#4920525)
Depending on move constructors scare the bajeezus out of me because I have no way of knowing if it's working properly. It's behavior is also implementation specific. Given the following test you'll get a variety of results depending on your platform.

struct Foo{...} std::vector<Foo> vec; for( int i = 0; i < 10; ++i) { vec.push_back( Foo() ); }

Results: 35 move / 25 copy / 10 move + 15 copy / 25 move.

It all depends on your compiler and STL implementation. Not knowing scares the hell out of me.

Re:Stroustrup on next-gen C++: I didn't want to let go of my... by CJefferson on Friday December 14, 2012 @09:33AM (#4921054)
I assume what you are saying is the following?

* Compilers are introducing move as we move in C++11. If you compile your code in C++03 (or a compiler with partial C++11 support, no move).

* The standard doesn't place a strict definition on how vectors are increased in size as you push_back. Of course, if you want to control the amount of space in a vector manually, rather than let your compiler decide, you can reserve in advance.

Is your problem just with moving to C++11, or do you get different numbers (other than different numbers of moves) in a compiler with proper C++11 support (basically, the most recent version of everything).

Re:Stroustrup on next-gen C++: I didn't want to let go of my... by ksherlock on Friday December 14, 2012 @09:44AM (#4921101)
Re:Stroustrup on next-gen C++: I didn't want to let go of my... by shawn-butler on Friday December 14, 2012 @09:27AM (#4921023)
I don't understand your comment. Please try the following:

vec.reserve(10);

and report back how many allocations occur.

Re:Stroustrup on next-gen C++: I didn't want to let go of my... by shawn-butler on Friday December 14, 2012 @09:48AM (#4921117)
At this point assuming your team makeup hasn't changed much, have you been able to generate any intesting metrics to guage the increase in productivity?

Also what compiler did you feel comfortable picking a year ago to base a production development effort on?