Issue with C++ getter that returns Noesis::String by value
Posted: 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:
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' ?
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:
Code: Select all
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);
}
};
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' ?