What is an efficient way to compute pq, where q is an integer?
Assuming that ^ means exponentiation and that q is runtime variable, use std::pow(double, int).
EDIT: For completeness due to the comments on this answer: I asked the question Why was std::pow(double, int) removed from C++11? about the missing function and in fact pow(double, int) wasn't removed in C++0x, just the language was changed. However, it appears that libraries may not actually optimize it due to result accuracy concerns.
Even given that I would still use pow until measurement showed me that it needed to be optimized.