Rather than fabricate up special undecipherable abstract examples, here is some code directly out of the project on which I'm currently working. Here is the template declaration:
template<class Precision, class VoiceClass, int32 numChannels, int32 maxVoices, class GlobalParameterStorage>
VoiceProcessorImplementation<Precision, VoiceClass, numChannels, maxVoices, GlobalParameterStorage>::VoiceProcessorImplementation (float sampleRate, GlobalParameterStorage* globalParameters)
{
}
Here is the calling code which invokes it:
voiceProcessor = new VoiceProcessorImplementation<float, Voice<float>, 2, MAX_VOICES, GlobalParameterState> ((float)processSetup.sampleRate, ¶mState);
This is working. I didn't actually write this code, it's from an example project I used as a "starting point" for my own project.
Here is what I want to change - in the template declaration (parameter list), VoiceClass is a parameter which represents a class with a constructor expecting no arguments. I have changed the signature of the constructor of VoiceClass so that it now expects a single parameter/argument, of class XXX.
How do I syntactically change these two statements (above) so the invoking call will pass a single argument of class XXX to the template, which will in turn pass that argument on the VoiceClass constructor?
I am embarrassed to admit how much time I have wasted trying to figure this out. Pages and pages of documents of cryptic articles on C++ templates and template specialization have been digested, and I'm as confused as ever.
Can anyone help me? Please, if possible, no long winded abstractions on the finer points of C++, my brain is tired. I just need to get this undoubtedly simple syntactical change in place so I can continue with my project.
Thanks in advance!
template<class Precision, class VoiceClass, int32 numChannels, int32 maxVoices, class GlobalParameterStorage>
VoiceProcessorImplementation<Precision, VoiceClass, numChannels, maxVoices, GlobalParameterStorage>::VoiceProcessorImplementation (float sampleRate, GlobalParameterStorage* globalParameters)
{
}
Here is the calling code which invokes it:
voiceProcessor = new VoiceProcessorImplementation<float, Voice<float>, 2, MAX_VOICES, GlobalParameterState> ((float)processSetup.sampleRate, ¶mState);
This is working. I didn't actually write this code, it's from an example project I used as a "starting point" for my own project.
Here is what I want to change - in the template declaration (parameter list), VoiceClass is a parameter which represents a class with a constructor expecting no arguments. I have changed the signature of the constructor of VoiceClass so that it now expects a single parameter/argument, of class XXX.
How do I syntactically change these two statements (above) so the invoking call will pass a single argument of class XXX to the template, which will in turn pass that argument on the VoiceClass constructor?
I am embarrassed to admit how much time I have wasted trying to figure this out. Pages and pages of documents of cryptic articles on C++ templates and template specialization have been digested, and I'm as confused as ever.
Can anyone help me? Please, if possible, no long winded abstractions on the finer points of C++, my brain is tired. I just need to get this undoubtedly simple syntactical change in place so I can continue with my project.
Thanks in advance!