I have just been burned by the following.
If I want to initialize a std::vector of n elements with a constant X I do this:
std::vector<double> v(n, X);
But if I need to initialize a std::valarray of n elements with a constant X I need to swap the size and initializing constant:
std::valarray<double> va(X, n);
This seems to me like an arbitrary 'gotcha'.
Is there a technical reason or some design rationale provided by the standards committee when deciding about the order of the fill constructor's parameters when std::vector and std::valarray were standardized?
Because they don't come from the same place:
vectorcomes from the STL library, andvalarraydoesn't (I haven't been able to find out where it comes from, but there seem to be strong connections to Fortran).Quoting Bjarne himself:
(From "Evolving a language in and for the real world: C++ 1991-2006".)
So I would say that the rationale is the traditional C++ one, "things are the way they are, and changing them for the sake of Standardization would break a lot of things, so let's leave well enough alone".