From: Scott Meyers on
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

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

From: johannes.dahlstrom on
On Mar 17, 7:58 am, Scott Meyers <NeverR...(a)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


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

From: Scott Meyers on
johannes.dahlstrom(a)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

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

From: Paul Bibbings on
Scott Meyers <NeverRead(a)aristeia.com> writes:

> johannes.dahlstrom(a)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

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

From: johannes.dahlstrom on
On Mar 19, 11:11 am, Scott Meyers <NeverR...(a)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


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