Partial template specialization issues

Hello.

Is there anyway for me to accomplish something as follows where the specialised template is only specialised for a number of parameters (in this case 1), rather than them all?

Thanks,
Uni
template<typename TA, typename TB=int>
class CClass{
};
 
template<>
class CClass<typename TA, double>{
};

Open in new window

LVL 3
Unimatrix_001Asked:
Who is Participating?
 
jkrCommented:
Yes, that can be done, only the syntax  is different:
template<typename TA, typename TB=int>
class CClass{
};
 
template<typename TA>
class CClass<TA,double>{
};

Open in new window

0
 
Let_Me_BeCommented:
Yes, but only in the opposite direction (left to right).
template < typename A, typename B >
class SomeClass
{
    A a;
    B b;
};
 
template < typename B >
class SomeClass<int,B>
{
    int a;
    B b;
};

Open in new window

0
 
Unimatrix_001Author Commented:
Yeugh... this template business just keeps getting uglier every turn! :(
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Unimatrix_001Author Commented:
Ack - accepted too early... jrk mind opening this question please?
0
 
Unimatrix_001Author Commented:
Yes if you wouldn't mind. Thanks.
0
 
Let_Me_BeCommented:
Sorry for the confusion :)

For some reason I had really stored in my memory that you have to do partial specialization from left to right (and I can't figure out why).
0
 
Unimatrix_001Author Commented:
LMB, don't let it worry you. ;) Not a problem at all.

Uni.
0
 
Unimatrix_001Author Commented:
...and closed again! ;)
0
 
Unimatrix_001Author Commented:
Cheers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.