How to use different overload of an inline function, depending on a compile time parameter?
问题 I have a performance critical inline function, inline T func(T a, T b, int p) . It can be optimized quite a bit, if p is known to be zero. However, I can't use an 'if' and penalize all the the other cases. What I want is to optimize the function only of I know at compile-time that p is zero. Is there a clean way to do that, maybe using template magic? EDIT I can't use differently named function/incompatible overloads (I don't know ho to express that correctly) since the code is very low level