Help with C++ template specialization...

Discussion in 'C Programming' started by odlumb, Nov 5, 2014.

  1. odlumb

    odlumb

    Joined:
    Nov 5, 2014
    Messages:
    2
    Likes Received:
    1
    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, &paramState);

    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! :)
     
    odlumb, Nov 5, 2014
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David B. Held
    Replies:
    2
    Views:
    601
    Rob Williscroft
    Oct 26, 2003
  2. Dave
    Replies:
    4
    Views:
    8,311
    pdixtl
    Jun 4, 2010
  3. pit3k
    Replies:
    8
    Views:
    556
    Victor Bazarov
    Feb 9, 2005
  4. case2005
    Replies:
    3
    Views:
    2,124
    Nicolas Pavlidis
    Feb 13, 2005
  5. Ruben Campos
    Replies:
    3
    Views:
    6,818
    jacobsson@gmail.com
    Feb 15, 2005
  6. BigMan
    Replies:
    1
    Views:
    722
    davi.reis@gmail.com
    Mar 26, 2005
  7. Siegfried Heintze
    Replies:
    2
    Views:
    409
    Siegfried Heintze
    Feb 2, 2006
  8. Joseph Turian
    Replies:
    2
    Views:
    726
    andy@servocomm.freeserve.co.uk
    Apr 16, 2006
Loading...