22

We are going to start a long lasting project using C++ as the programming language.

I read that C++0x is going to come out in 2011, so they called it C++11.

When C++11 comes out, we will still be developing the project, and would like to know if it is possible to use any features of the new C++ standard now, to able to:

  • code faster than with the old C++ and
  • switch easily when the new standard arrives?
Leonardo
  • 2,439
  • 6
  • 26
  • 27
camelord
  • 285
  • 3
  • 14
  • 6
    Which platform/compiler are you planning to use? – dirkgently Mar 16 '10 at 09:19
  • There is no compiler limitation. The only requirement is using the Rogue Wave Library.. so i am free with compiler settings. – camelord Mar 16 '10 at 09:33
  • Do you have any sources for the "C++11" name? – Joachim Sauer Mar 16 '10 at 09:53
  • 3
    @Joachim Herb Sutter in the article here http://herbsutter.wordpress.com/2010/03/13/trip-report-march-2010-iso-c-standards-meeting/ suggests such a name change can only take place once the standard is actually published. –  Mar 16 '10 at 09:59
  • http://herbsutter.wordpress.com/2010/03/13/trip-report-march-2010-iso-c-standards-meeting/ – camelord Mar 16 '10 at 10:03
  • 1
    @camelord To quote "If we [publish it next year] we can stop with the “x-is-hex” jokes and just start calling it C++11." But it hasn't been published yet, so we are stuck with C++0x. –  Mar 16 '10 at 10:15
  • You will not be able to wish away problems by using the next and upcoming standard. I dare say, it'd add to your problems should the compiler's implementation be buggy (a case in point will be `volatile` semantics which most compilers don't get right). Figure out why you need the next standard, if at all, then see if publicly available libraries like Boost help alleviate the problem or not. If there is a feature that is worth investing a lot of compiler testing time -- go ahead with the next standard and the next compiler. – dirkgently Mar 16 '10 at 10:24
  • @Neil: What "name change"? The standard doesn't have a name yet, so there is nothing to change. C++0x is just a placeholder name, nothing official or ISO-approved. – jalf Mar 16 '10 at 12:51
  • @jalf I'm just paraphrasing Sutter. –  Mar 16 '10 at 12:53

6 Answers6

14

This page shows the parts of C++0x supported by gcc(main Unix compiler), MSVC(main Microsoft compiler) and a few others(including Intel). Extra info for Clang is here although I think their c++ support for current standards is still incomplete.

Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
13

Just because a standard comes out does not mean that the compilers magically get updated - it took years for most compilers to provide reasonable support for the previous standard, and some features never got supported much, such as export (dropped from C++0x). Depending on first implementations of new features si not a great strategy either - I prefer to let others be experimenters, if I'm working to a deadline.

Also, I wouldn't be too fast to call it C++11 - the standards process is fraught with possibilities for delay.

Edit: I see you are using the RW libraries. In which case, probably many features of the new Standard won't be of immediate interest, as they are aimed at template writers and users of the C++ Standard library.

  • 2
    using the new standard does not mean the 'old' C++ cannot be used anymore. Meaning the software architekture can be build that way to use old C++ as interface to the RW Library and the new C++ for the rest of the Application.. – camelord Mar 16 '10 at 09:48
  • Not "magically", through hard work. I think (hope?) that C++0x compilers will be in fairly good shape when the standard is published. For example I'm sure Sutter has said on his blog that MS is shadowing the drafts as closely as it practically can, and that it currently intends for its first major release after publishing to be compliant (anyway as compliant as it currently is to C++03, so as good as you're used to). I'd have thought one of the more likely reasons for a significant publishing delay is if one or more major compilers highlights difficulties in implementing the changes. – Steve Jessop Mar 16 '10 at 14:31
  • @Steve: Don't suppose you have a link to that statement from Sutter? Anyway, if they can pull off a reasonably compliant version by 2012'ish (which is presumably when the next VS is targeted for), that'd be nice. :) – jalf Mar 16 '10 at 18:00
  • @jalf: sorry, can't find it by searching. When I say "I'm sure", that's exaggeration: "I think". It's possible I've mis-remembered comments about partial C++0x support. Please don't base your business plan on my fallible memory of Sutter's non-promise ;-) – Steve Jessop Mar 16 '10 at 18:14
  • Well, i guess i just work with the new MFC and TB1. Seems like it can last a long time to use a C++0x Release. Thx for youre answers.. – camelord Mar 17 '10 at 09:02
4

Visual C++ 2010 and latest gcc versions (-std=c++0x) have support for new features of C++11, but not all of them. In particular, you could start using the new initializer syntax with braces; that is IMHO the biggest syntax change in C++11. It is also the change that would add the most inconsistencies in your code, if one part uses C++98 style and the other uses C++11 style.

Didier Trosset
  • 36,376
  • 13
  • 83
  • 122
4

Scott Meyers (author of the "Effective C++" series) uploaded just last week the following:

Summary of C++0x Feature Availability in gcc and MSVC

This is, in a sense, similar to another link mentioned in a different answer on this thread. The main difference is that Meyers' link only contains stuff he's tried out himself. I expect it will keep getting updated in the months to come.

Also, and this is how I found out about this, he implied on comp.std.c++ that he is working on something related to C++0x educational material (apparently beyond his training course) but this is all too speculative right now, so let's just stick to the first link I provided above.

Alexandros Gezerlis
  • 2,221
  • 16
  • 21
2

Don't think of it as switching to all the new features at once. Evaluate each new language feature on it's own merits, and the quality of its implementation.

For instance long long has been a fairly common compiler extension even before it was considered for C++0x, and the new auto syntax is useful and likely to be well-supported. You may want to be very cautious with some complicated combination of several new features like type inference with decltype for a function with the new -> syntax inside a class using variadic templates and the new rules for parsing >>.

P-Nuts
  • 879
  • 5
  • 6
1

it depends which compiler you are using.

As an example, GCC has the tr1 extension which contains some features that will be in C++11.

Johan Kotlinski
  • 25,185
  • 9
  • 78
  • 101
  • There is no compiler limitation. The only requirement is using the Rogue Wave Library.. so i am free with compiler settings. – camelord Mar 16 '10 at 09:33