How do I simplify this templated vector initializer loop using lambdas or some kind of STL transform
Posted
by Neil G
on Stack Overflow
See other posts from Stack Overflow
or by Neil G
Published on 2010-04-16T20:51:22Z
Indexed on
2010/04/16
20:53 UTC
Read the original article
Hit count: 251
How do I simplify this templated vector initializer loop using lambdas or some kind of STL transform?
template<typename T>
template<typename... Args>
DotProduct<T>::DotProduct(int n, RNG& rng, Args const&... args) {
myBasis.resize(n);
for (auto it = myBasis.begin(); it != myBasis.end(); ++it) {
typename T::CPDDist cpd(rng, args...);
*it = T(cpd);
}
}
© Stack Overflow or respective owner