×

Discussion Board

Results 1 to 3 of 3

Hybrid View

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    6

    Template specialization involving Template class

    I have this template signature:

    template<typename T>
    TBool Foo(const T& aData)
    {
    }

    The problem is providing template specializations for something which is already a template itself eg a TBuf.

    We came up with this method which compiles and works for winscw but not armv5:

    template<>
    template <const TInt N>
    inline TBool Foo<TBufC8<N> > (const TBufC8<N>& aData)
    {
    }

    Error from compilation for armv5 is:

    Error: #777: this declaration cannot have multiple "template <...>" clauses
    inline TBool Foo<TBufC8<N> > (const TBufC8<N>& aData)

    Any ideas anyone?

    Thanks,

    Chi

  2. #2
    Regular Contributor
    Join Date
    Nov 2005
    Location
    Aalborg, Denmark
    Posts
    296

    Re: Template specialization involving Template class

    Hi cajagu,
    Use overloading:

    Code:
    template<const TInt N>
    inline TBool Foo(const TBufC8<N>& aData)
    {
    }
    But maybe you should consider using a specialization for TDesC instead.. Typically we pass descriptors by the base class i.e. TDesC or TDes.

    // Morten

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    6

    Re: Template specialization involving Template class

    Thanks Morten.

    I do have a non-template overload of this function which takes TDesC but the compiler would always choose the template function which is why I wanted to provide a specialization for the different descriptors (at the bottom of the heirarchy)... I had already tried this method you suggested but there was an error: "illegal template declaration"

    Chi

    Quote Originally Posted by mollevp View Post
    Hi cajagu,
    Use overloading:

    Code:
    template<const TInt N>
    inline TBool Foo(const TBufC8<N>& aData)
    {
    }
    But maybe you should consider using a specialization for TDesC instead.. Typically we pass descriptors by the base class i.e. TDesC or TDes.

    // Morten

Similar Threads

  1. ARMI - THUMB
    By adrianogalati in forum Symbian
    Replies: 6
    Last Post: 2007-10-23, 19:57
  2. Replies: 2
    Last Post: 2007-03-14, 17:15
  3. 求助:N9200 Series SDK上的问题
    By youpengli in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 3
    Last Post: 2004-05-10, 02:56
  4. definition of class method outside class body?
    By advocatee in forum Symbian
    Replies: 2
    Last Post: 2003-07-02, 07:09
  5. Exceptions while loading application
    By avinash_rs in forum Mobile Java General
    Replies: 0
    Last Post: 2003-06-09, 10:53

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •