次のように、テンプレート クラス内でいくつかのテンプレート メンバー メソッドを定義したいと思います。
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;
}
しかし、テンプレート クラスをインスタンス化するときに、3 つの引数メソッド定義に関するエラーがあります。
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"
私が間違っていることを教えてください。(2 番目) の方法は問題ないのに、(3 番目) の方法ではコンパイル時にエラーが発生するのはなぜですか?