Converting a project from Codeblocks to Visual Studio I encountered this puzzling error from the compiler:
Error 4 error C2228: left of '.swap' must have class/struct/union
shared_ptr.hpp
Error 3 error C2440: '<function-style-cast>' : cannot convert from
'boost::shared_ptr<T>' to 'boost::shared_ptr<T>' shared_ptr.hpp 384
Here’s the code in question in boost’s shared_ptr.hpp
template<class Y>
shared_ptr & operator=( shared_ptr<Y> && r ) // never throws
{
this_type( static_cast< shared_ptr<Y> && >( r ) ).swap( *this );
return *this;
}
I set up a similar but less complicated project and did not get the same error.
You probably try to swap two
shared_ptrof incompatible types. Make sure that the twoshared_ptrpoint to objects of the same/convertible type.