
On 28/02/2020 21.01, Bardur Arantsson wrote:
On 28/02/2020 19.48, Oleg Grenrus wrote:
std::vector<int> variantC; variantC.reserve(100); for (int i = 0; i < 100; i++) { primitive.push_back(f(i)); }
I'm not a fan of changing `fromListN` to be partial function, but if that change is carried on in `vector` there should be a variant which allows to `reserve` without worrying about partiality.
- Oleg
Interestingly, reserve actually is a size hint in the sense of "must be equal or greater than".
(Apogies for the self-reply, I fired that one off a bit early.) That said, the expectation in C++ is the you *will* be mutating a vector, so expecting further push_back(), etc. might be reasonable. In 'vector', maybe not so much? Regards,