How to declare the reflection for a template cpp class
Hi Noesis,
So supposing I have a template class like this:
How should I fill in for say class type in this macro?
and
These are what I have tried but just no success:
I'm not sure it is even allowed though.
Thanks.
So supposing I have a template class like this:
Code: Select all
static constexpr const char sControlTypeName[] = "CustomControlType";
template <class Type, const char* Param = sControlTypeName>
class FCustomControl : public Noesis::UserControl
{};
Code: Select all
FCustomControl<float, sControlTypeName>
Code: Select all
NS_DECLARE_REFLECTION(<?>, UserControl)
Code: Select all
NS_IMPLEMENT_REFLECTION(<?>, "CustomControl")
Code: Select all
NS_DECLARE_REFLECTION(FCustomControl, UserControl)
NS_IMPLEMENT_REFLECTION(FCustomControl<float, sControlTypeName>, "CustomControl"){}
Thanks.
Re: How to declare the reflection for a template cpp class
Oh I tried:
and it compiles.
Code: Select all
NS_IMPLEMENT_INLINE_REFLECTION_(FCustomControl, UserControl, Noesis::IdOf("CustomControl<", Noesis::IdOf<Type>(), ">"))
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: How to declare the reflection for a template cpp class
As you found the reflection for templated classes should be defined inside the class definition using NS_IMPLEMENT_INLINE_REFLECTION macro.
If you want to use those custom controls in xaml I suggest you use a name that doesn't contain '<' '>' characters, something more like:
If you want to use those custom controls in xaml I suggest you use a name that doesn't contain '<' '>' characters, something more like:
Code: Select all
NS_IMPLEMENT_INLINE_REFLECTION_(FCustomControl, UserControl, Noesis::IdOf(Noesis::IdOf<T>(), "CustomControl"))
Re: How to declare the reflection for a template cpp class
Yeap, thanks for your confirmation! Indeed, if I use say "CustomControl<float>", there will be an error about some invalid token.
Who is online
Users browsing this forum: Bing [Bot] and 58 guests