Me gustaría definir algunos métodos miembros de la plantilla dentro de una clase de plantilla de este modo:error "demasiados plantilla de parámetros de las listas" cuando especializada una función miembro
template <typename T>
class CallSometing {
public:
void call (T tObj); // 1st
template <typename A>
void call (T tObj, A aObj); // 2nd
template <typename A>
template <typename B>
void call (T tObj, A aObj, B bObj); // 3rd
};
template <typename T> void
CallSometing<T>::call (T tObj) {
std::cout << tObj << ", " << std::endl;
}
template <typename T>
template <typename A> void
CallSometing<T>::call (T tObj, A aObj) {
std::cout << tObj << ", " << aObj << std::endl;
}
template <typename T>
template <typename A>
template <typename B> void
CallSometing<T>::call (T tObj, A aObj, B bObj) {
std::cout << tObj << ", " << aObj << ", " << bObj << ", " << std::endl;
}
Pero cuando instantializing la clase de plantilla, hay un error con respecto a la definición del menthod de tres argumentos:
CallSometing<int> caller;
caller.call(12); // OK
caller.call(12, 13.0); // OK
caller.call (12, 13.0, std::string("lalala!")); // NOK - complains "error: too many template-parameter-lists"
¿Podría señalar lo que estoy haciendo mal? ¿Por qué el (2 °) método está bien pero el (3 °) causa un error de tiempo de compilación?
Aghhhhh, +1 por ser cuatro segundos más rápido. :-D –
@James: No fue cuatro segundos después, fue tres segundos antes. ':)' – sbi