I'm having a hard time specializing a class.
The template class takes these template parameters:
Now, I want to specialize the class so that it's possible to only supply the parameter for Type.
typename ParamPolicy<Type>::Type (Class::* GetFunction)(),
void (Class::* SetFunction)(typename ParamPolicy<Type>::Type)
Unfortunately, it's only possible to specialize the class, which means I have to supply arguments for the rest of the template parameters:
Of course, this isn't allowed (compile error).
template<typename Type> class CUtilityMember<Type, Dummy, NULL, NULL>
Another idea might be to put default arguments for Class, Get and Set (Dummy, NULL, NULL). However, I want to specialize the class to avoid memory overhead & stuff. So, I need a way to detect if Get and Set are NULL and if such case, perhaps derive from a special policy class.
But I can't find a way to detect if Get and Set are NULL. Even though they are template parameters, expressions such as "Get == NULL" will only result in a non-constant expression compile error.
(Compile error: non-constant expression.)
template<...> class CUtilityMember: private CCallbackPolicy<GetFunction == NULL && SetFunction == NULL>
Another idea I thought of was to specialize CCallbackPolicy for when Get & Set == NULL, but then I'm in the same mess as the first problem. Something about cannot have a non-dependant type in a dependant type in specialization:
template<typename Type, typename Class> class CCallbackPolicy<Type, Class, NULL, NULL>
Does anyone know of a good way to actually accomplish this or am I once again asking for the impossible?
Templates can be so ... unflexible. I just wish they would fix that!