How do I simplify this templated vector initializer loop using lambdas or some kind of STL transform?
template<typename T>
template<typename... Args>
void InitToRandomValues(vector<T>* retval, int n, RNG& rng, Args const&... args) {
retval->resize(n);
for (auto it = retval->begin(); it != retval->end(); ++it) {
typename T::CPDDist cpd(rng, args...);
*it = T(cpd);
}
}