This appears to be a difference in how bind is implemented in MS Visual Studio (including 2010) and GNU gcc (I tested 4.4.1 and 4.5.2, both of which work the way you expected) Consider the following code, given your definitions auto be = boost::bind(&MenuItem); NoncopyableObject obj(7); b(obj); // OK in VS and GCC replacing boost::bind with std::bind (I'm using 2010, the error message appears to be the same as in your 2008) auto be = std::bind(&MenuItem); NoncopyableObject obj(7); b(obj); // compile error in VS 2010 SP1, OK in GCC b(std::reference_wrapper(obj)); // OK in both So, what happens is that MS's bind() makes a copy of its argument even if the argument is not going to be used, while boost's and GCC's bind() does not bother with that argument at all I was able to get your example to compile and run (on 2010) by changing the FUNC typedef to typedef boost::function1 FUNC.
This appears to be a difference in how bind is implemented in MS Visual Studio (including 2010) and GNU gcc (I tested 4.4.1 and 4.5.2, both of which work the way you expected) Consider the following code, given your definitions auto be = boost::bind(&MenuItem); NoncopyableObject obj(7); b(obj); // OK in VS and GCC replacing boost::bind with std::bind (I'm using 2010, the error message appears to be the same as in your 2008) auto be = std::bind(&MenuItem); NoncopyableObject obj(7); b(obj); // compile error in VS 2010 SP1, OK in GCC b(std::reference_wrapper(obj)); // OK in both So, what happens is that MS's bind() makes a copy of its argument even if the argument is not going to be used, while boost's and GCC's bind() does not bother with that argument at all. I was able to get your example to compile and run (on 2010) by changing the FUNC typedef to typedef boost::function1 FUNC.
Thank you so much for this. Employing reference_wrapper does the trick. I think there's one slight error in your answer: the line of code b(std::reference_wrapper(obj)); // OK in both should be using std::ref (or std::tr1::ref) instead I think?
– PUK Jul 12 at 7:41 @PUK You're right, using the ref() helper function when making the function call is a bit easier to read. It's the same as using make_pair(arg1, arg2) instead of pair(arg1, arg2); – Cubbi Jul 12 at 12:56 How silly of me. Of course - it's going via a function for with template argument deduction.
Thanks! – PUK Jul 13 at 9:22.
This appears to be a difference in how bind is implemented in MS Visual Studio (including 2010) and GNU gcc (I tested 4.4.1 and 4.5.2, both of which work the way you expected).
Their purpose is to compare functors, but I needed to cover a special case for the boost. Bind type of functors.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.