M
MikeWhy
I want to override a template class method on a formal parameter. Is this
possible without redefining everything else in the class? The alternative is
a "conditional is constant" warning. For example, call Reset() only when
AutoReset is true:
template <bool AutoReset, class T>
class TimerNode {
....
void OnTimer();
void DoCall();
};
//----------------------
template <class T>
void TimerNode<true, T>::OnTimer()
{
Reset();
DoCall();
}
//----------------------
template <class T>
void TimerNode<false, T>::OnTimer()
{ DoCall();
}
MSVC 2008 complains:
error C3860: template argument list following class template name must list
parameters in the order used in template parameter list
error C3855: 'CallbackTimerT<AutoReset,TickProc>': template parameter
'AutoReset' is incompatible with the declaration
error C2976: 'CallbackTimerT<AutoReset,TickProc>' : too few template
arguments
error C3860: template argument list following class template name must list
parameters in the order used in template parameter list
possible without redefining everything else in the class? The alternative is
a "conditional is constant" warning. For example, call Reset() only when
AutoReset is true:
template <bool AutoReset, class T>
class TimerNode {
....
void OnTimer();
void DoCall();
};
//----------------------
template <class T>
void TimerNode<true, T>::OnTimer()
{
Reset();
DoCall();
}
//----------------------
template <class T>
void TimerNode<false, T>::OnTimer()
{ DoCall();
}
MSVC 2008 complains:
error C3860: template argument list following class template name must list
parameters in the order used in template parameter list
error C3855: 'CallbackTimerT<AutoReset,TickProc>': template parameter
'AutoReset' is incompatible with the declaration
error C2976: 'CallbackTimerT<AutoReset,TickProc>' : too few template
arguments
error C3860: template argument list following class template name must list
parameters in the order used in template parameter list