const int thing = 1234;
int func( int hello )
{
return hello / (thing*123+321);
}
Is (thing*123+321) computed in compile time?
If thing was a user defined type with int operator* would it also happen in compile time?
If thing was a float or double would it also happen in compile time?
If I forcibly change thing in runtime would (thing*123+321) be unchanged?
There’s no guarantee that it will be, but any optimizing compiler will precompute this value. It will probably turn that division operation into a multiplication by a precomputed reciprocal value too.