4 ms·
> the object construction can be done with static methods I've done that a lot too, but I found that free functions are much better for this than static member
by Conscat 1y ago
> the object construction can be done with static methods
I've done that a lot too, but I found that free functions are much better for this than static member functions, because you can't get CTAD from static member functions. For example, with constructors we could write:
vector{1, 2, 3}; // deduces vector<int>
And with a static member, we would need:
vector<int>::init(1, 2, 3);
With a free function, we could write:
make_vector(1, 2, 3); // returns vector<int>