Bjarne Stroustrup on C++ 0x

time to read 2 min | 316 words

I used to dig C++ to the core, and I still have a couple of repeated fond nightmares about it :-)
This article talks about the next version of C++, likely to be C++ 09, and it has some nice features.
After a very quick scan:

auto - which tells the compiler to figure out the type on its own (similar to how var in C# 3.0 works).
Sequence constructors - which allows you to do this: vector<int> = { 1,2,3,5,7} (I just wished that I could have that in the CLR).
Partial template derivation - meaning that you can do declare a type that is still generic, but some of its types are binded. (This a generic dictionary whose key is bound to a string)
Concepts - Which I also talked about recently, allow you to specify what a type should look like, and it looks like that it is doing this regardless of inheritance, so anything that has a Name() method could be put in a naming container, for isntance.
The annoying double >> problem is gone, no more vector< std:string, vector<int> >, you can now proudly state vector<std:string, vector<int>>

The standard library will provide: Hash Tables, Regular expression, and more
For each that works nearly as easily as the .Net one

Take a look at the sample code, which will draw shapes to the screen:

template<Container C>
void draw all(C& c)
where Usable as<C::value type,Shape*>
{
 for each(c, mem fun(&Shape::draw));
}

vector<Shape*> v = {
 new Circle(p1,20),
 new Triangle(p1,p2,p3),
 new Rectangle(p3,30,20)
};

draw all(v);

list<shared ptr<Shape*>> v2 = {
 new Circle(p1,20),
 new Triangle(p1,p2,p3),
 new Rectangle(p3,30,20)
};

draw all(v2);

The only other languages that I can think of where I can produce a code this clear is Javascript & Boo. And it says something when I compare C++ to Boo