This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Nested Template function caused compile error in ccsv5



//used to convert  float to any type. 

template<typename _Tp>

static inline _Tp saturate_cast(float v)

{

     return _Tp(v);

}

//used to compute pow of float  val ,and return the value in any type you want;

template<typename _Tp> 

_Tp pow_f(float a)

{
return saturate_cast<_Tp>(a*a); ////compile error: #306 no instance of overloaded function "saturate_cast" matches the argument list 

}

int main(void) {
      pow_f<int>(3.1f);
      return 1;
}


thease codes can compiled in vs2008 ,but cann't compiled in ccsv5.....the error message is showed in red color.

  • I cannot compile the code above with GNU g++ 4.1.1, because pow_f needs to be a template function, like so:

    template<typename _Tp>
    static inline _Tp saturate_cast(float v)
    {
        return _Tp(v);
    }
    
    //used to compute pow of float  val ,and return the value in any type you want;
    
    template<typename _Tp>
    _Tp pow_f(float a)
    {
        return saturate_cast<_Tp>(a*a); ////compile error: #306 no instance of overloaded function "saturate_cast" matches the argument list 
    }
    
    int main(void) {
        pow_f<int>(3.1f);
        return 1;
    }
    

    When I add that line, it compiles just fine with TMS470 compiler version 5.0.2, but fails with version 5.0.1, with the error you indicate.  You probably need to upgrade to version 5.0.2 or higher.  I cannot find a specific SDSCM defect report covering this issue; I'll ask around.

  • I'm pretty sure this is the same bug as SDSCM00044909

  • thanks for point out the mistake, it's my input error..,  I had been update the compiler version. it works well now.