I have this code that doesn\'t work, but I think the intent is clear:
testmakeshared.cpp
#include
class A {
public:
stat
struct A {
public:
template std::shared_ptr static create(Arg&&...arg) {
struct EnableMakeShared : public A {
EnableMakeShared(Arg&&...arg) :A(std::forward(arg)...) {}
};
return std::make_shared(std::forward(arg)...);
}
void dump() const {
std::cout << a_ << std::endl;
}
private:
A(int a) : a_(a) {}
A(int i, int j) : a_(i + j) {}
A(std::string const& a) : a_(a.size()) {}
int a_;
};