realm_mike
Topic Author
Posts: 5
Joined: 05 May 2023, 06:03

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

24 May 2023, 07:03

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' ?
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

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

24 May 2023, 18:25

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)

Who is online

Users browsing this forum: Google [Bot] and 83 guests