Home Dashboard Directory Help

Compile error when explicitly instantiating shared_ptr by jmcmod


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 649531
Opened: 3/4/2011 5:01:54 PM
Access Restriction: Public
User(s) can reproduce this bug


Unable to use explicit instantiation on shared_ptr since upgrading to Visual Studio 2010.

I believe the problem exists in the routine below because _Mybase (which is _Ptr_base) does not have a swap method. It, instead, has a _Swap method.

    void swap(_Myt&& _Right)
        {    // exchange contents with movable _Right
        _Mybase::swap(_STD move(_Right));

I removed the explicit instantiation and it resolved my problem.

Note that the problem can also manifest via the following (granted it would be a strange thing to do):
std::tr1::shared_ptr<int> a;
a.swap(std::tr1::shared_ptr<int>(new int(1)));
Sign in to post a comment.
Posted by Microsoft on 3/7/2011 at 7:47 PM

Thanks for reporting this bug. We've already fixed it, and the fix will be available in VC11. According to the latest C++0x Working Paper, shared_ptr isn't supposed to have an rvalue swap, much less a broken one. We've removed it, allowing shared_ptr to be explicitly instantiated again.

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/6/2011 at 6:21 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/4/2011 at 5:14 PM
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.
File Name Submitted By Submitted On File Size  
TestSmartPtrSwap.cpp 3/4/2011 183 bytes