Friday, April 16, 2010

How do I simplify this templated vector initializer loop using lambdas or some kind of STL transform?

Programmer Question

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);
}
}


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails