I've got the following class definition:
class Portal
{
public:
Portal( const vector<vec3> &vertices, shared_ptr<Sector> target );
...
};
Somewhere else, I want to create an instanceof said class like this:
auto portal = make_shared<Portal>( portalVertices, target );
However, I get the following error message in Visual Studio 2010:
error C2668: 'boost::make_shared' : ambiguous call to overloaded function
Can anyone tell me why? I only define a single constructor. Thank you!
As you are using the keyword auto I assume you are using C++11 features.
C++11 also comes with std::make_shared
.
So, please try adding the namespace:
auto portal = std::make_shared<Portal>( portalVertices, target );
or
auto portal = boost::make_shared<Portal>( portalVertices, target );
So what I usually do in my code / the .C file is:
using namespace std; // this is a "using" directive
....
void somefunction() {
auto portal = make_shared<Portal>( ... );
}
As you mentioned you were specifying in your header
using boost::make_shared;
I would really like to see the full header file. As I think you actually wanted to have a using directive, but ended up in having a using declaration.
Have a look at this description:
using
directive: http://msdn.microsoft.com/en-us/library/aewtdfs3%28v=vs.80%29.aspx
using
declaration: http://msdn.microsoft.com/en-us/library/was37tzw%28v=vs.80%29.aspx