trying to compile old project that has many uses of shared_ptr with the vs2010. so, i have precompiled header (stdafx.h) with:
..
using namespace std; ..#include "boost/shared_ptr"
using namespace boost;
and later in the code i intensively use shared_ptr spObject;
What should I change in the stdafx.h so that I will no need to replace everywhere in the code *shared_ptr* to *some_namespace::shared_ptr*?
Is it possible to do without namespace conflicts of boost/boost::tr1/std::tr1/std?
Now I have a lot of errors:
error C2872: 'shared_ptr' : ambiguous symbol could be 'k:\boost10\boost\smart_ptr\shared_ptr.hpp(165) : boost::shared_ptr' or 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\memory(1418) : std::tr1::shared_ptr'
Don't put using namespace
in headers, as you've discovered it can break headers that follow, and because you can't change those headers there isn't much you can do about it.
At function scope you can use a using declaration to disambiguate:
void f()
{
using std::tr1::shared_ptr;
shared_ptr<int> p;
}
But that won't work in the global namespace, because you've already polluted that scope with the careless using directives.