Peng, The space between the ++ and i is fine. Some find ++i more readable, that is all.
It is difficult to optimize away the repeated f(n) calls because f() could have side effects and there is no guarantee it will always return a constant. If f() always returns a constant, this could potentially be optimized by interprocedural constant propagation(IPCP) IPCP work is being done on the ipa branch but I don't think it is safe to assume whether it will be optimized. If your f() returns a constant, your best bet is to do: for (int i =0, j = f(n); i < j; ++i) { } Regards, Ryan Mansfield _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus