You are right actually with your first comment.
I fell foul here of basically trying to code to the values of EClassCastFlags without actually reading what they represented.
I had written a switch/case on that, and included all the possible values, and then worked over most of them removing the values that I obviously would never encounter in my case and letting them fall into the default: case.
What had confused me at the time was CASTCLASS_UEnum vs CASTCLASS_FEnumProperty
I thought I was going to need to handle the UEnum and didn’t realise they would (obviously) be FEnumProperty, which I had already coded for much as you mentioned.
If I had only changed my test case to include an enum, I would have seen that it was already working - but I didn’t because I thought it would automatically fail.
The code I ended up using is pretty much the same as the other cases:
case CASTCLASS_FEnumProperty:
{
FEnumProperty* PropEnum_2 = CastField<FEnumProperty>(PropertyToSet);
if (uint8* ValuePtr = PropEnum_2->ContainerPtrToValuePtr<uint8>(ObjectToFill))
*ValuePtr = (uint8)Value.IntVal;
break;
}
Thank you for making me look properly at my code