Summary of C++0x Feature Availability

1788 views
Skip to first unread message

Scott Meyers

unread,
Mar 6, 2010, 8:15:12 PM3/6/10
to
I've put together a summary of C++0x support in gcc and MSVC, and I think this
summary may be useful to others. It's now available at
http://www.aristeia.com/C++0x/C++0xFeatureAvailability.htm .

Both C++0x and compiler support for it are moving targets, so the information in
the summary will get out of date over time, and of course there may be errors in
the summary as it stands now. My goal is to keep the summary both accurate and
up to date, so if you see anything that needs improvement, please let me know:
sme...@aristeia.com.

Thanks,

Scott

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Brian

unread,
Mar 7, 2010, 3:29:38 AM3/7/10
to
On Mar 6, 7:15 pm, Scott Meyers <NeverR...@aristeia.com> wrote:
> I've put together a summary of C++0x support in gcc and MSVC, and I think this
> summary may be useful to others. It's now available athttp://www.aristeia.com/C++0x/C++0xFeatureAvailability.htm.
>
> Both C++0x and compiler support for it are moving targets, so the information in
> the summary will get out of date over time, and of course there may be errors in
> the summary as it stands now. My goal is to keep the summary both accurate and
> up to date, so if you see anything that needs improvement, please let me know:
> smey...@aristeia.com.
>

To summarize the summary, it looks like gnu, intel and microsoft
are leading the pack. Whereas HP, IBM and Sun are falling
behind.


Brian Wood
http://webEbenezer.net
(651) 251-9384

Scott Meyers

unread,
Mar 7, 2010, 5:00:00 PM3/7/10
to
Brian wrote:
> To summarize the summary, it looks like gnu, intel and microsoft
> are leading the pack. Whereas HP, IBM and Sun are falling
> behind.

Something else worth taking away from the summary is that there is a *lot* of
C++0x available to play with right now. auto, lambdas, rvalue references,
variadic templates, uniform initialization, nullptr, decltype, static_assert,
default and deleted functions, unique_ptr, forward_list, regular expressions,
and a whole bunch more are at your disposal. Alas, no compiler (that I know of)
offers all these things at the same time, but for purposes of playing around
with different features (and many combinations of features), C++0x is your oyster.

Scott

Mathias Gaunard

unread,
Mar 8, 2010, 4:05:12 AM3/8/10
to
On 7 mar, 01:15, Scott Meyers <NeverR...@aristeia.com> wrote:
> I've put together a summary of C++0x support in gcc and MSVC, and I think this
> summary may be useful to others. It's now available athttp://www.aristeia.com/C++0x/C++0xFeatureAvailability.htm.

You give the current support of a MSVC beta, but not that of the 4.5
branch of GCC?

Scott Meyers

unread,
Mar 8, 2010, 2:17:20 PM3/8/10
to
Mathias Gaunard wrote:
> You give the current support of a MSVC beta, but not that of the 4.5
> branch of GCC?

Right, sorry. I give information for what I personally checked. If it makes
you feel any better, I don't give information for MSVC 10 RC, which came out
recently. I haven't had time to do any testing with that compiler, either.

Scott

Mathias Gaunard

unread,
Mar 9, 2010, 8:18:14 AM3/9/10
to
On 8 mar, 19:17, Scott Meyers <NeverR...@aristeia.com> wrote:
> Mathias Gaunard wrote:
> > You give the current support of a MSVC beta, but not that of the 4.5
> > branch of GCC?
>
> Right, sorry. I give information for what I personally checked. If it makes
> you feel any better, I don't give information for MSVC 10 RC, which came out
> recently. I haven't had time to do any testing with that compiler, either.

The reference link you provided for GCC provides status for both 4.4
and 4.5. I assumed you used that.

Scott Meyers

unread,
Mar 9, 2010, 12:38:36 PM3/9/10
to
Mathias Gaunard wrote:
> The reference link you provided for GCC provides status for both 4.4
> and 4.5. I assumed you used that.

I didn't put together any information on any compiler I didn't personally check.
Given the interest in gcc 4.5 and the availability of information for it, I
will add a column for it when I have the time -- by the end of the month, I hope.

Scott

Bart van Ingen Schenau

unread,
Mar 10, 2010, 2:10:59 PM3/10/10
to
On Mar 9, 6:38 pm, Scott Meyers <NeverR...@aristeia.com> wrote:
> Mathias Gaunard wrote:
> > The reference link you provided for GCC provides status for both 4.4
> > and 4.5. I assumed you used that.
>
> I didn't put together any information on any compiler I didn't personally check.
> Given the interest in gcc 4.5 and the availability of information for it, I
> will add a column for it when I have the time -- by the end of the month, I hope.

Perhaps you could state on the coverpage that you only report on
compilers (-versions) that you have tested yourself, and that you are
not just summarising information from the vendors.

>
> Scott
>
Bart v Ingen Schenau

Scott Meyers

unread,
Mar 11, 2010, 2:53:48 PM3/11/10
to
Bart van Ingen Schenau wrote:
> Perhaps you could state on the coverpage that you only report on
> compilers (-versions) that you have tested yourself, and that you are
> not just summarising information from the vendors.

Fair enough. I'll add that when I get the chance.

Scott

Herb Sutter

unread,
Mar 14, 2010, 10:27:17 PM3/14/10
to
On Sun, 7 Mar 2010 16:00:00 CST, Scott Meyers
<Neve...@aristeia.com> wrote:
>Brian wrote:
>> To summarize the summary, it looks like gnu, intel and microsoft
>> are leading the pack. Whereas HP, IBM and Sun are falling
>> behind.

I'm just glad that Microsoft isn't at the very back of the conformance
pack this time. :-)

>Something else worth taking away from the summary is that there is a *lot* of
>C++0x available to play with right now. auto, lambdas, rvalue references,
>variadic templates, uniform initialization, nullptr, decltype, static_assert,
>default and deleted functions, unique_ptr, forward_list, regular expressions,
>and a whole bunch more are at your disposal. Alas, no compiler (that I know of)
>offers all these things at the same time, but for purposes of playing around
>with different features (and many combinations of features), C++0x is your oyster.

And yesterday we voted out the C++0x FCD. (Woo-hoo!) Modulo bug fixes
and corner cases, this should be It.

I didn't realize how much of a turning point this week would feel
like, at least for me personally. It was kind of like I felt rather
than heard a distant "click" somewhere of the pieces snapping
together: the committee agreeing that the feature list is now final;
the implementations of key features starting to be delivered into real
customers' hands; the availability of many features in multiple
shipping implementations this year -- including multiple shipping
implementations available by this summer of auto, for loops, move
semantics, lambdas, and more that I'm probably forgetting; and Bjarne
starting work in earnest on TC++PL 4e.

It also struck me this week that this feels a lot like the mid/late
1990s again -- a new standard is coming that is adding significant
features to the language, and actual compiler implementations still
vary. There's a lot of room again for teaching material about how to
learn the new features, how to know what's portable today and what's
not, how to write code in a future-proof way that's portable today and
will stay portable tomorrow but also be ready to take advantage of new
features, etc.

Hmm, maybe it's time...

---
Herb Sutter (herbsutter.wordpress.com)
(www.gotw.ca)
Convener, ISO/IEC JTC1/SC22/WG21 (C++) (www.gotw.ca/iso)
Visual C++ architect, Microsoft (www.gotw.ca/microsoft)

Scott Meyers

unread,
Mar 17, 2010, 1:58:34 AM3/17/10
to
Herb Sutter wrote:
> I'm just glad that Microsoft isn't at the very back of the conformance
> pack this time. :-)

Since I'm on record for taking MS to task for its lousy conformance last time
'round ( http://www.artima.com/cppsource/top_cpp_software.html ), I'm happy to
say that I've been very pleased with the C++0x features (both language and
library) available in the freely-available VC10. (My primary experience is with
the betas, but the RC is out now at
http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx .) The combination of
auto, lambdas, rvalue references, nullptr, and nearly the entire set of library
extensions has been a true pleasure to work with. It'd be sweet to have the
concurrency stuff, too, but nobody has that yet, as far as I know.

Between gcc 4.4 and VC10 (the two compilers I've been experimenting with), I
don't think there is a reasonable way to say which one is "more" conformant. Of
the two, only MS has lambdas, for example, while only gcc has variadic
templates, default and deleted functions, and uniform initialization. For
playing around purposes (i.e., where you try lots of different things and
combinations of things to see how they work), I prefer VC10. My preference may
change once gcc 4.5 comes out, but right now, my subjective opinion is that far
from trailing the pack, MS is arguably leading it.

To have such an influential vendor putting significant effort into implementing
the nascent revised standard is a boon to all people interested in C++
development. From a standards-conformance point of view, I'd say that VC10
makes up for VC6. (Which I guess means that from my perspective, 10 isn't the
new 6, it's the new anti-6.)

Scott

johannes....@gmail.com

unread,
Mar 18, 2010, 6:52:45 PM3/18/10
to
On Mar 17, 7:58 am, Scott Meyers <NeverR...@aristeia.com> wrote:

> It'd be sweet to have the concurrency stuff, too,
> but nobody has that yet, as far as I know.

g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.
Alas, not yet any of the really fancy stuff like futures. Please take
a look at the example I hobbled together a while ago:

http://lilja.asteriski.fi/~sharlin/procon3.cpp

Johannes

Scott Meyers

unread,
Mar 19, 2010, 5:11:28 AM3/19/10
to
johannes....@gmail.com wrote:
> g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.

Hmmm. Given

#include <thread>
#include <mutex>

int main()
{
std::thread t;
std::mutex m;
}

I get:

g++ (TDM-1 mingw32) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

threads.cpp: In function 'int main()':
threads.cpp:6: error: 'thread' is not a member of 'std'
threads.cpp:6: error: expected ';' before 't'
threads.cpp:7: error: 'mutex' is not a member of 'std'
threads.cpp:7: error: expected ';' before 'm'

> Alas, not yet any of the really fancy stuff like futures. Please take
> a look at the example I hobbled together a while ago:
>
> http://lilja.asteriski.fi/~sharlin/procon3.cpp

My copy of gcc can't compile your code, either:

g++ (TDM-1 mingw32) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

jd.cpp:28: error: expected type-specifier
jd.cpp:28: error: expected '>'
jd.cpp:35: error: ISO C++ forbids declaration of 'unique_lock' with no type
jd.cpp:35: error: typedef name may not be a nested-name-specifier
jd.cpp:35: error: expected ';' before '<' token
jd.cpp:47: error: type 'work_pool<T, Container, Mutex>' is not derived from
type 'work_pool<T, Container, Mutex>::handle'
jd.cpp:47: error: expected ';' before 'lock_type'
jd.cpp:126: error: 'lock_type' does not name a type
jd.cpp:137: error: 'condition_variable' in namespace 'std' does not name a type
jd.cpp: In constructor 'work_pool<T, Container,
Mutex>::handle::handle(work_pool<T, Container, Mutex>::handle&&)':
jd.cpp:51: error: class 'work_pool<T, Container, Mutex>::handle' does not
have any field named 'lock'
jd.cpp: In constructor 'work_pool<T, Container,
Mutex>::handle::handle(work_pool<T, Container, Mutex>&)':
jd.cpp:123: error: class 'work_pool<T, Container, Mutex>::handle' does not
have any field named 'lock'
jd.cpp: At global scope:
jd.cpp:145: error: template argument 3 is invalid
jd.cpp: In function 'void produce(int, int&, const std::atomic<bool>&)':
jd.cpp:152: error: 'std::this_thread' has not been declared
jd.cpp:155: error: request for member 'lock' in 'pool', which is of non-class
type 'int'
jd.cpp:155: error: unable to deduce 'auto' from '<expression error>'
jd.cpp: At global scope:
jd.cpp:169: error: template argument 3 is invalid
jd.cpp: In function 'void consume(int, int&, const std::atomic<bool>&)':
jd.cpp:176: error: request for member 'lock' in 'pool', which is of non-class
type 'int'
jd.cpp:176: error: unable to deduce 'auto' from '<expression error>'
jd.cpp:187: error: 'std::this_thread' has not been declared
jd.cpp: In function 'int main()':
jd.cpp:196: error: template argument 3 is invalid
jd.cpp:196: error: invalid type in declaration before '(' token
jd.cpp:200: error: 'thread' was not declared in this scope
jd.cpp:200: error: template argument 1 is invalid
jd.cpp:200: error: template argument 2 is invalid
jd.cpp:200: error: invalid type in declaration before ',' token
jd.cpp:204: error: request for member 'emplace_back' in 'consumers', which is
of non-class type 'int'
jd.cpp:204: error: 'cont' was not declared in this scope
jd.cpp:205: error: request for member 'emplace_back' in 'producers', which is
of non-class type 'int'
jd.cpp:208: error: 'this_thread' has not been declared
jd.cpp:214: error: request for member 'begin' in 'producers', which is of
non-class type 'int'
jd.cpp:214: error: request for member 'end' in 'producers', which is of
non-class type 'int'
jd.cpp:214: error: 'thread' is not a class, namespace, or enumeration
jd.cpp:215: error: request for member 'begin' in 'consumers', which is of
non-class type 'int'
jd.cpp:215: error: request for member 'end' in 'consumers', which is of
non-class type 'int'
jd.cpp:215: error: 'thread' is not a class, namespace, or enumeration

Any idea why our results are different?

Scott

Paul Bibbings

unread,
Mar 20, 2010, 3:18:02 AM3/20/10
to
Scott Meyers <Neve...@aristeia.com> writes:

> johannes....@gmail.com wrote:
>> g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.
>
> Hmmm. Given
>
> #include <thread>
> #include <mutex>
>
> int main()
> {
> std::thread t;
> std::mutex m;
> }
>
> I get:
>
> g++ (TDM-1 mingw32) 4.4.1
> Copyright (C) 2009 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> threads.cpp: In function 'int main()':
> threads.cpp:6: error: 'thread' is not a member of 'std'
> threads.cpp:6: error: expected ';' before 't'
> threads.cpp:7: error: 'mutex' is not a member of 'std'
> threads.cpp:7: error: expected ';' before 'm'

<snip />

> Any idea why our results are different?
>
> Scott

I see you're attempting to compile under MinGW. Try:

#include <thread>
#include <iostream>

int main()
{
#if !defined(_GLIBCXX_HAS_GTHREADS)
std::cout << "glib doesn't have gthreads on my platform\n";
#endif
}

In the gcc c++0x headers, _GLIBCXX_HAS_GTHREADS is a wrapper for the new
threading capabilities.

I don't know the exact details, but I have the same problems with
gcc-4.4.3 (i686-pc-cygwin-gcc) on Windows. Obviously implementations of
gcc require glib to have gthreads support, but I have yet to find (or
build) an implementation for Windows - whether under Cygwin or MinGW -
that can achieve this.

As for the precise reasons why gthreads support seems not to be
available under Windows (if that's not too bold an assertion), I have
not yet gone that far in my investigations.

Regards

Paul Bibbings

johannes....@gmail.com

unread,
Mar 20, 2010, 3:17:18 AM3/20/10
to
On Mar 19, 11:11 am, Scott Meyers <NeverR...@aristeia.com> wrote:
>
> Any idea why our results are different?
>

My compilation environment:

$ uname -a; gcc -v
Linux aurora 2.6.31-20-generic-pae #58-Ubuntu SMP Fri Mar 12 06:25:51
UTC 2010 i686 GNU/Linux
[snip]
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)


It seems that MinGW, being "minimal", doesn't have a pthreads
emulation layer and thus none of the library components dependent on
pthreads, either (and nobody has yet written a libstdc++0x
implementation using native Windows threads...)

The Cygwin project at http://cygwin.com/ offers a much more complete
POSIX environment including pthreads, but they don't have GCC 4.4
binaries available yet. Oh well. The GCC folks claim that vanilla GCC
compiles cleanly on Cygwin should you like to get adventurous...


Johannes

Mathias Gaunard

unread,
Mar 20, 2010, 4:21:15 AM3/20/10
to
On 19 mar, 09:11, Scott Meyers <NeverR...@aristeia.com> wrote:

> johannes.dahlst...@gmail.com wrote:
> > g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.
>
> Hmmm. Given
>
> #include <thread>
> #include <mutex>
>
> int main()
> {
> std::thread t;
> std::mutex m;
> }
>
> I get:
>
> g++ (TDM-1 mingw32) 4.4.1
> Copyright (C) 2009 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> <lots of errors>

Works fine for me with GCC 4.4.1 on Ubuntu Linux, using -std=c++0x.

Vadim Zeitlin

unread,
Mar 20, 2010, 4:21:25 AM3/20/10
to
On 2010-03-19, Scott Meyers <Neve...@aristeia.com> wrote:
> johannes....@gmail.com wrote:
>> g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.
>
> Hmmm. Given
>
> #include <thread>
> #include <mutex>
>
> int main()
> {
> std::thread t;
> std::mutex m;
> }
>
> I get:
>
> g++ (TDM-1 mingw32) 4.4.1
> Copyright (C) 2009 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> threads.cpp: In function 'int main()':
> threads.cpp:6: error: 'thread' is not a member of 'std'
> threads.cpp:6: error: expected ';' before 't'
> threads.cpp:7: error: 'mutex' is not a member of 'std'
> threads.cpp:7: error: expected ';' before 'm'
...

> Any idea why our results are different?

Probably because thread support is not implemented for mingw32 yet. It
does seem to be available in e.g. Linux version of g++ and, I guess, other
platforms using POSIX threads.

The example above compiles for me with g++ 4.4.3 (Debian 4.4.3-3) provided
-std=c++0x is specified (otherwise the following error occurs:

/usr/include/c++/4.4/c++0x_warning.h:31:2: error: #error This file requires
compiler and library support for the upcoming ISO C++ standard, C++0x. This
support is currently experimental, and must be enabled with the -std=c++0x
or -std=gnu++0x compiler options.

)

Regards,
VZ

Scott Meyers

unread,
Mar 21, 2010, 4:10:25 AM3/21/10
to
johannes....@gmail.com wrote:
> g++ 4.4 has threads, atomics, locks, mutexes, and condition variables.
> Alas, not yet any of the really fancy stuff like futures.

I revised the spreadsheet to indicate that on Unix platforms, gcc 4.4 apparently
supports these features. (I say "apparently" only because I have not tested
this functionality myself.)

I also modified the spreadsheet to reflect the existence of noexcept.

Thanks for helping me make the information in the spreadsheet more accurate.

Scott

Anthony Williams

unread,
Mar 25, 2010, 3:08:01 PM3/25/10
to
Scott Meyers <Neve...@aristeia.com> writes:

> It'd be sweet to have the
> concurrency stuff, too, but nobody has that yet, as far as I know.

gcc has some of the thread library stuff in 4.4, and more in 4.5, but
it's still not complete.

However, that's why I've written the just::thread C++0x thread
library. It provides a complete implementation of the C++0x thread
library from the current working draft for VS2008, VS2010 (new in the
V1.3.2 release), and g++ 4.3 and 4.4 for Ubuntu linux. See
http://www.stdthread.co.uk for details.

There were a few changes to the thread library voted into the standard
at Pittsburgh, so shortly after the FCD is published, I'll be releasing
V1.4 with the corresponding changes. All existing customers will get a
free upgrade.

Anthony
--
Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/
just::thread C++0x thread library http://www.stdthread.co.uk
Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Dilip

unread,
Apr 7, 2010, 1:56:00 AM4/7/10
to
On Mar 6, 8:15 pm, Scott Meyers <NeverR...@aristeia.com> wrote:
> I've put together a summary of C++0x support in gcc and MSVC, and I think this
> summary may be useful to others. It's now available athttp://www.aristeia.com/C++0x/C++0xFeatureAvailability.htm.
>
> Both C++0x and compiler support for it are moving targets, so the information in
> the summary will get out of date over time, and of course there may be errors in
> the summary as it stands now. My goal is to keep the summary both accurate and
> up to date, so if you see anything that needs improvement, please let me know:
> smey...@aristeia.com.

In addition to your summary, this post is also quite informative:
http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx

Scott Meyers

unread,
Apr 30, 2010, 7:07:32 AM4/30/10
to
Dilip wrote:
> In addition to your summary, this post is also quite informative:
> http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx

I've added a link to this page to my C++0x feature availability summary.

Scott

--
* C++ and Beyond: Meyers, Sutter, & Alexandrescu, Oct. 24-27 near Seattle (http://cppandbeyond.com/)
* License my training materials for commercial (http://tinyurl.com/yfzvkp9) or personal use (http://tinyurl.com/yl5ka5p).

Reply all
Reply to author
Forward
0 new messages