views:

798

answers:

6

With the official release of VS 2010, is it safe for me to start using the partially-implemented C++0x feature set in my new code?

The features that are of interest to me right now are both implemented by VC++ 2010 and recent versions of GCC. These are the only two that I have to support.

In terms of the "safety" mentioned in the first sentence: can I start using these features (e.g., lambda functions) and still be guaranteed that my code will compile in 10 years on a compiler that properly conforms to C++0x when it is officially released?

I guess I'm asking if there is any chance that VC++ 2010 or GCC will end up like VC++ 6; it was released before the language was officially standardized and consequently allowed grossly ill-formed code to compile.

After all, Microsoft does say that "10 is the new 6". ;)

+8  A: 

The C++0X feature set is pretty fixed by now, so I'd say go for it. The final draft of the proposal should be done in august according to wikipedia.

A lot of the things are available from boost anyway (actually, a lot of 0X things come from boost) - see boost TR1. You can re-use those features through boost even if the compiler isn't fully C++0X.

MadKeithV
Read it again. The FCD is already out, the FDIS isn't plan to be put out to vote until March 2011.
KTC
A: 

I guess I'm asking if there is any chance that VC++ 2010 or GCC will end up like VC++ 6; it was released before the language was officially standardized and consequently allowed grossly ill-formed code to compile.

It is possible to happen, but very unlikely, IMHO. Not only MS, but other compiler vendors as well are already supporting some C++0x features and I would expect the Standard Committee to be extremly careful about breaking compatibility at this point.

Nemanja Trifunovic
A: 

Much of the important things (ie things you would typically use often) are pretty much set in stone. I think the risk of writing code that becomes non-standard is extremely low, especially if you stick to a subset of the spec implemented on current compilers.

For a good table listing the support for features go here. Personally auto variables, r-value references, and lambdas are pretty much the big features to use and are well supported.

Ron Warholic
A: 

As long as you're ok with the code not being able to be compiled on an older compiler, then you have nothing to lose and might as well take advantage of the new features.

Dave Johansen
+12  A: 
Noah Roberts
Great, thanks for the heads up!
svu2g
A: 

If you expect your code to be untouched for years and want it to survive compiler changes with no intervention I would suggest you stick to C++98/03.

However most code is maintained over time so I don't think this is such an important consideration. I would recommend using what makes your code better and plan for some work when you upgrade compilers.

Motti
Why C++98 instead of C++03?
Roger Pate
@Roger Right you are.
Motti
C++98 and C++03 are pretty much the same, save for a few bugfixes
Joe D