RE: [Boost-users] boost::bind, MSVC7.1 and volatile-qualification
I wonder why gcc is able to compile it. :-)
Well considering that the following also yields different results on MSVC7.1 and gcc 3.2/3.3 I would wonder if there is a problem with one of the compilers
#include <iostream>
#include
Do you really have a volatile member function somewhere? I thought that they were "officially" worthless.
Well, that is a different matter. If one might want to follow Andrei's suggestion of using volatile to encapsulate synchronisation then they are still worthwhile. (CUJ February 2001).
Schalk_Cronje@McAfee.com wrote:
Do you really have a volatile member function somewhere? I thought that they were "officially" worthless.
Well, that is a different matter. If one might want to follow Andrei's suggestion of using volatile to encapsulate synchronisation then they are still worthwhile. (CUJ February 2001).
I wouldn't go that way. After the great flame wars in comp.programming.threads regarding the article, Andrei himself has acknowledged that this might not be the proper way to do sychronization. He's since proposed a better approach. http://www.informit.com/articles/article.asp?p=25298
Schalk_Cronje@McAfee.com wrote:
I wonder why gcc is able to compile it. :-)
Well considering that the following also yields different results on MSVC7.1 and gcc 3.2/3.3 I would wonder if there is a problem with one of the compilers
#include <iostream> #include
struct X { void f() {std::cout << "None" << std::endl;} void f() const {std::cout << "const" << std::endl;} };
[...]
int main() { X x; boost::bind(&X::f, _1)(x); }
&X::f is ambiguous in boost::bind(&X::f, _1). boost::bind can't figure out which one you want, so it picks one at random. The example is actually similar to the one below; your "run" overloads accept an object and can be ordered, but the bind expression does not. boost::mem_fn(&X::f) is similarly ambiguous. #include <iostream> struct X { void f() {} void f() const {} }; template <class T> void mem_fn( void (T::*f_)() ) { std::cout << "None" << std::endl; } template <class T> void mem_fn( void (T::*f_)() const ) { std::cout << "const" << std::endl; } int main() { mem_fn(&X::f); }
participants (2)
-
Peter Dimov
-
Schalk_Cronje@McAfee.com