Hello,I had some probems with template specialization, so I have a proposal: allow partial template specialization for function and ordinary members of a templated class.In some situation it could be useful to define partial template specialization for functions, for example:template <int N, class T>
void function(void);
template <int N, class T>
void function<N, T>(void) {}
template <class T>
void function<42, T>(void) {}
In other situations you may want to create a class with methods whose behaviour depends on the template parameters, for example:template <int N, class T>
class Foo
{
// #1
void test(void);
// ...
};
template <class T>
class Foo<2, T>
{
// #2
void test(void);
// ...
};
template<int N, class T>
void Foo<N, T>::test(void) { /* belongs to #1 */ }
template<class T>
void Foo<7, T>::test(void) { /* belongs to #1 */ }
template<class T>
void Foo<2, T>::test(void) { /* belongs to #2 */ }
This could be very useful in some situation, such as creating a vector or a matrix class where you need some common methods and you want to partially specialize them for few cases. Of course it is possible to use some other strategies, for example declaring a partially specialized copy of the classes for each case, but it would be tedious, error prone end it could create some difficulties in maintainance.Why does the standard currently non feature this?Do you believe such a proposal would makes sense? I think this would imply only few changes, am I right?Thanks for consideration.Best regards,Luca Ciucci.--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals