julian
julian

Reputation: 5

The block in hpp file,Is this a c++ syntax ?why there is no parameters passed in?could someone explain it ,please?

-----------.h files----------------

Here is the head files,there is no problem in this file, I can understand everything in this file.

template <int ALGO>

class FFTRealUseTrigo

{

public:

    typedef FFTRealFixLenParam::DataType DataType;  //就因为这个玩意,所以这个类要写成模板类
    typedef OscSinCos<DataType> OscType;

    FORCEINLINE static void prepare(OscType& osc);
    FORCEINLINE static void iterate(OscType& osc,DataType& c,DataType& s,const DataType cos_ptr[],long index_c,long index_s);


private:

    FFTRealUseTrigo();
    ~FFTRealUseTrigo();
    FFTRealUseTrigo(const FFTRealUseTrigo& other);
    FFTRealUseTrigo& operator=(const FFTRealUseTrigo& other);
    bool operator ==(const FFTRealUseTrigo& other);
    bool operator !=(const FFTRealUseTrigo& other);
};

--------------------------.hpp files-----------------------------------------

Here is the hpp file. there comes the problem.since there are implementations of iterator and prepare,what are those two functions without parameters? an over ride?(seems not)

#include "OscSinCos.h"
#include "FFTRealUseTrigo.h"


template <int ALGO> void FFTRealUseTrigo <ALGO>::prepare(OscType& osc)

{

    osc.clear_buffers();

}


template <> void FFTRealUseTrigo <0>::prepare(OscType& osc) //What is this? 

{

    //Nothing

}

template <int ALGO> void FFTRealUseTrigo <ALGO>::iterate(OscType& osc, DataType& c,DataType& s,const DataType cos_ptr[],long index_c,long index_s)

{

    osc.step();
    c=osc.get_cos();
    s=osc.get_sin();

}

**template <> void FFTRealUseTrigo <0>::iterate(OscType& osc,DataType& c,DataType& s,const DataType cos_ptr[],long index_c,long index_s)** //since there is an implementation of iterator,what is this function?

{

    c=cos_ptr[index_c];
    s=cos_ptr[index_s]; //这个真的没看懂了,上一个是Nothing,这一个还有实现

}

#endif

Upvotes: 0

Views: 44

Answers (1)

Paul Belanger
Paul Belanger

Reputation: 2434

That is an explicit template specialization. Basically, when you instantiate a template, any full specializations will be used if available before a generic version is used. This can be done to optimize special cases for algorithms, and is also useful in template metaprogramming for things like type traits and template recursion.

Upvotes: 1

Related Questions