3 ms·
As per usual with c++ it depends. In some situations things are guaranteed to be compile time evaluated. E.g. even in early templates this would need to work:
by sour-taste 2y ago
As per usual with c++ it depends. In some situations things are guaranteed to be compile time evaluated. E.g. even in early templates this would need to work:
Func<1+2>();
Something like this there's no guarantees around:
template <A, B>
int Func() {
return A + B;
}
For almost all compilers it should constant fold this into a constant but in theory it could end up with an add instruction. Basically we can't second guess the author here because it depends on the specifics.