Friend function is unable to construct a unique pointer of the class
问题 I have a certain design strategy where the constructor of my class is private and can only be constructed by friends of the class. Inside the friend function, I am trying to create a unique_pointer of my class using std::make_unique but it doesn't compile. My VC12 compiler complains c:\program files (x86)\microsoft visual studio 12.0\vc\include\memory(1639): error C2248: 'Spam::Spam' : cannot access private member declared in class 'Spam' The relevant code which fails during compilation is as