how to prevent people from creating an instance of class, but only create a shared pointer? I am doing something like:
class OnlyShred
{
public:
friend std::shared_ptr<OnlyShred> make_shared()
{
return std::make_shared<OnlyShred>();
};
private:
OnlyShred() = default;
OnlyShred(const OnlyShred&) = delete;
OnlyShred(const OnlyShred&&) = delete;
OnlyShred& operator=(const OnlyShred&) = delete;
};
Could you please confirm if this is ok? And if you can think of a downside doing this? The instance can not be copied/moved so this must gurantee that only shared pointer is around when someone uses this class?