
Peter Dimov wrote: [...]
An implementation can do that if it wants to, but I don't want to impose it as a requirement. It's better to allow use_count() to lag behind in MT code for performance reasons, because idiomatic weak_ptr use does not rely on the latest value anyway.
Agreed.
It's PDQ in practice (unless you have a compiler smart enough to ignore volatile hack and use a cached copy in spite of it because you're not supposed to noticed the difference according to the MT memory model rules).
You need to insert lots of "in theory" here.
* "volatile" is specifically intended to prevent "smartness".
Your use of a volatile variable is indistinguishable (no change in behavior whatsoever) from a non-volatile variable if/when run single-thread.
No, it's not; C++ behavior _is defined in terms of_ volatile (and I/O calls), not the other way around.
As if rule. And C++ says nothing about mutiple threads. http://groups.google.com/groups?selm=4152B42E.2B271094%40web.de regards, alexander.