Open Jean1995 opened 2 years ago
I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.
I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.
Isn't it common to provide such helper function within an API?
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);