Yes, this one was asked before , and the answer was:
valarray (arrays of values) are designed to port some Fortran speed to C ++. You would not make valarray pointers so that the compiler can make assumptions about the code and optimize it better. (The main reason Fortran is so fast is because there is no pointer, so there can be no smoothing of the pointer.)
or
valarray should also eliminate any possibility of smoothing [...]
But these answers make no sense to me.
valarray and vector are class templates and, as such, they do not even exist until instantiation.
And, of course, vector<int> does not cause problems with an alias more than valarray<int> does.
Given this, what was the purpose of valarray , and why didn't they just add the same functionality to vector ?
source share