How to NewObject with a UClass parameter?

I want to do something like this:

void switchState(UClass* stateClass) {
	const FString stateClassName = stateClass->GetName();
	if (stateMap.Contains(stateClassName)) {
		state = stateMap[stateClassName];
	} else {
		state = NewObject<???>(this); // <- ??? should be what?
		state->characterRef = this;
		stateMap.Add(stateClassName, state);
	}
}

There is a version of NewObject that takes the class as parameter.
The template type only specifies how to cast its return value.

state = NewObject<UObject>(this, stateClass);