Answer the question
In order to leave comments, you need to log in
How to correctly declare a friend function in a class?
Hello. Errors appeared after switching to Visual Studio 2013. I have the following code:
class Data
{
public:
typedef boost::shared_ptr<Data> s_ptr;
friend s_ptr boost::make_shared<Data>(int const & d); // c2063, c4346, c2998
static s_ptr create(int id) { return boost::make_shared<Data>(id); }
private:
explicit Data(int id): id_(id) {}
};
error C2063: 'boost::make_shared' : not a function
warning C4346: 'boost::make_shared' : dependent name is not a type
prefix with 'typename' to indicate a type
error C2998: 'make_shared' : cannot be a template definition
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question