Seached for this, but can't find a similar question. If there is one please close this question. This isn't my real code, just an example to demonstrate :-
#include <iostream>
// Normal template class with a destructor
template <class T> class Test
{
public:
~Test() { std::cout << "Normal \n";}
};
// Partial specialization for arrays
template<class T> class Test<T[]>
{
public:
~Test() { std::cout << "Array \n"; }
};
int main()
{
Test<int[3]> i;
}
When I compile this it does not call the specialized version for arrays. If I replace the template with
template<class T> class Test<T[3]>
{
public:
~Test() { std::cout << "Array \n"; }
};
Then it does call the specialization but I want this to be called for any array not just ones of a specifed size. Is there any way to write a specialization that gets used for all arrays?