You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Isn't it common to provide such helper function within an API?
What is the benefit of writing or reading:
auto cuts = make_energy_cuts(2, 1, false);
over?
auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);
It's 10 characters shorter, yes. But you loose the type information completely. The second version is completely clear that it creates a std::shared_ptr<EnergyCutSettings>.
Don't optimize the number of typed characters if it hurts something else.
When creating EnergyCutSettings, one has to explicitly create a shared ptr in C++:
auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);
There should be a create function this does this, as it is already implemented for other objects as well:
auto cuts = make_energy_cuts(2, 1, false);
The text was updated successfully, but these errors were encountered: