ice
ice copied to clipboard
Consider using factory methods for classes that enable_shared_from_this and have init methods
In a few place we have separate init methods because you cannot call std::shared_from_this from a constructor.
void foo = make_shared<Foo>();
foo->init();
An alternative is to have a factory method createFoo that calls init, to avoid forgetting this additional initialization step.
We use the make_shared and init pattern in Slice library, PHP, Ruby and Python extensions. Probably in more places.