2017-11-06 6 views
0

----------- .hファイル----------------hppファイル内のブロック、これはC++構文ですか?なぜパラメータが渡されていないのですか?誰か説明できますか?

ここにはヘッドファイルがありますが、このファイルに問題はありませんが、私はこのファイルのすべてを理解することができます。

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ファイル----------- ------------------------------

ここにhppファイルがあります。問題が発生します。イテレータの実装と準備があるので、パラメータを持たない2つの関数は何ですか?オーバーライド?(思われない)

#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 
+0

おそらく、テンプレートの仕組みについてお読みください。 –

+0

あなたはテンプレートの仕組みについて何かを読んでみる必要がありますか? – julian

答えて

1

これはexplicit template specializationです。 基本的には、テンプレートをインスタンス化するときに、ジェネリック版が使用される前に完全な特殊化があればそれが使用されます。これは、アルゴリズムの特殊なケースを最適化するために行うことができ、template metaprogrammingではタイプ特性やテンプレート再帰などにも役立ちます。

関連する問題