> C++11 has this option: > > for (auto& item : container) { > // iterate over the container object, > // get a reference to each item > // > // "container" can be an STL class or > // A C-style array with known size. > } > > Which does this: > > for item in container: > pass >
It is even better than using the macro way because the compiler knows everything is constant (start and end), so it can do better things. > > Using C++ templates to generate ufunc loops is an obvious application, > > but again, in the simple examples > > Template metaprogramming? > > Don't even think about it. It is brain dead to try to outsmart the > compiler. > It is really easy to outsmart the compiler. Really. I use metaprogramming for loop creation to optimize cache behavior, communication in parallel environments, and there is no way the compiler would have done things as efficiently (and there is a lot of leeway to enhance my code). -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion