AnsweredAssumed Answered

VDSP++ Function templates inside a class template

Question asked by mef526 on Aug 16, 2011
Latest reply on Aug 17, 2011 by GrahamA

I am developing C++ code using templates. I am getting the following error:
"..\..\..\Common\Cpp\ADI\..\IntVectorPackT.h", line 299: cc0790:  error: explicit specialization is not allowed in the current scope
  template <> inline static memsize_t memorySize<true>(memsize_t size)


I am using a function template in the class template. This code runs fine in VS2010. I examined the c++ standard: ISO/IEC 14882:1998(E) and it seems like the code conforms to the standard in chapter 14 for function templates.


Can you examine the code and determine if there are any obvious problems in the syntax?


Here is the code:
template <typename T, typename TINT, typename Tint, int bits> class IntVectorPackT
    : public VectorBase




     /// memorySize(): get the number of chunks in memory for a given number of vector items
    /// A template allows the compiler to call the correct
    /// function rather than have run time code parse the type size
    template <bool TintIsPacked>
    inline static memsize_t memorySize(memsize_t size);


     template <> inline static memsize_t memorySize<true>(memsize_t size)
        memsize_t sz = (size / _kItemsPerMemdata);
        if (size % _kItemsPerMemdata)
        return sz;
    template <> inline static memsize_t memorySize<false>(memsize_t size)
    { return (size * _kMemdatasPerItem); }


// Here is a call to the FN template:
    IntVectorPackT& setup(memsize_t capacity) {
        VectorBase::setup( memorySize<_kItemsPerMemdata != 0>(capacity));
        return init<_kItemsPerMemdata != 0>(capacity);