Monday, March 3, 2008

C++0x: An overview

Bjarne Stroustrup

The basics rarely change.
Sat, Mar 1: C++ standards meeting, stuff voted in (lambda functions).
C++ supports OO, generic programming, etc.
The best solutions often cross these boundaries.

C++ Ox aims
· better language for systems programming and library building
· being easier to teach/learn.

Portability = good efficiency at the bottom and good abstraction at the top.
In C++Ox the x may be 9, or hexadecimal.
Google ‘WG21’ for details or to track standards committee.
Essentially all new standard libraries are available now: boost.org, M$, etc
Features are starting to appear in compilers (suggestions: experiment with them now, don’t put in production code yet).

C++ Ox ideals
· Maintain stability and compatibility
· Prefer libraries to language extensions
· Prefer generality to specialization
· Fit into existing toolchains

Language summary: ~35 new features!
Libraries summary: ~11 new libraries – RE, Threads, Networking, etc (all are now available)

Area of language change
· Machine model and concurrency (writings will come out within 2 weeks – search ‘WG21’
o Thread library
o Thread local storage
o Atomic ABI
o Async message bufer
· More support for generic programming
· Improved enums, long long, C99 character types, static_assert
· Initializations
· Postponed:
o Modules and dynamic linked libraries
o Programmer controlled garbage collection

Initalizer lists

template class vector {
// ...
vector(std::initializer_list); // sequence constructor
// ...
};

vector v = {1, 2, 3, 4};
vector heroes = {“Bjarne”, “Booch”};

Also:

void f(int, std:: initializer_list, int);
f(1, {1,2,3,4}, 5);
f(1, {1,a,x+y}, 0);

Lambda functions

Example: [](int x) { return x<7; }

Also:

[&x] grab x by reference
[x] copy x
[&] grab everything by reference

“C++0x will be a better tool than C++98 – much better.”

No comments: