How do I make a template specialization that takes 2 parameters versus the normal 1?
I was building a pointer class and now I thought about extending to make an array but if I try something like this:
template<class T,int s> class pointer{};
template<class T> class pointer{};
class mama{};
int main(){
pointer<mama> m;
}
It gives me an error. Template… redeclared with 1 parameter.
I need it specialized because pointer<mama,10> has size() and operator[] while pointer<mama> doesn’t, it has operator-> and *.
You could make a general template for the array case:
Then a partial specialization:
By defining a specialized version for the case where size=0, you can actually give that a totally different implementation, but with the same name.
However, it might be clearer just to give it a different name.