Home Dashboard Directory Help

std::ref works incorrectly with classes that overload operator & by Barfy


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 651285
Opened: 3/14/2011 6:52:56 AM
Access Restriction: Public
User(s) can reproduce this bug


std::ref works incorrectly when passed a reference to an object whose class overloads operator &. Boost's boost::ref provides correct result in this case.
Sign in to post a comment.
Posted by Microsoft on 6/17/2011 at 6:02 PM

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11. We now use std::addressof() to avoid overloaded operator&() in several more places. I can't guarantee that we've gotten them all (the STL is big and saying &elem is easy - not to mention difficult to grep for), but we've got a test that audits all containers, all container iterators, (reverse/move/istream)_iterator from <iterator> plus our non-Standard (checked/unchecked)_array_iterator, shared_ptr/weak_ptr/unique_ptr, ref()/cref()/reference_wrapper, and mem_fn(). As time permits we'll add to this test in order to scan more and more of the STL.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 3/15/2011 at 10:50 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for review. We will contact you if we require any additional information.
Posted by Microsoft on 3/14/2011 at 7:13 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.