[cpp] infer TEnumParameter enum from the field because the expression might be Dynamic (closes #2988)