Page 1 of 1

Issue with C++ getter that returns Noesis::String by value

Posted: 24 May 2023, 07:03
by realm_mike
Hi,

I have a struct that I'm trying to reflect where the getter function creates a Noesis::String for the UI 'just in time' as it's needed for the UI:
struct Message : Noesis::BaseComponent
{
	MessageInternal* pMessage;

	Noesis::String GetText() const
	{
		std::string s;
		pMessage->GetText(&s);
		return Noesis::String(s.c_str());
	}

	NS_IMPLEMENT_INLINE_REFLECTION(Message, Noesis::BaseComponent)
	{
		NsProp("Text", &Message::GetText);
	}
};
However this is throwing a compile error, and I believe the reason is that the internal TypePropertyFunction is only considering a getter that returns a const T& because IsBestByCopy<String> is false.

Can you adjust the internal template deduction logic so that you detect that the getter doesn't support returning a const T& and can fall back to ByCopy even though it's not 'Best' ?

Re: Issue with C++ getter that returns Noesis::String by value

Posted: 24 May 2023, 18:25
by jsantos
Please, file a ticket about this although I think this is something we cannot fix in 3.2 (probably we will need a major version for this change and more things pending in the reflection architecture)