What do you assume when you see fromListN in a library?

Bardur Arantsson spam at scientician.net
Fri Feb 28 20:01:05 UTC 2020


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".

(According to cppreference.com, anway.)



More information about the Libraries mailing list