Cannot convert from FString to T

Hey all,

I’ve create a template function, which needs to return a string, but evidently, there is no way I can find to return strings because the compiler throws an error regarding conversion from types of string to type T. I’ve tried returning FString, char*, TChar*, std:string, all of which get the same error C2440 ‘return’: cannot convert from ‘FString’ to 'T’

Code looks like the following:

template <typename T>
T UCustomComponent::GetParameter(T DefaultParameter, FString ParameterOverride)
{
	FString TestString = "Some text";
	return TestString;
}

(There was obviously other stuff going on in the function with the parameters, but just to demonstrate I cut out all other code and just try returning a single FString, which fails compilation with error C2440)

Is there anyway I can return a string as type T?

1 Like

same problem here…
but i have this error