template <typename T>
struct S {
T myValue;
S(T&);
template <typename... Ts>
S(Ts&&...);
};
Suppose I wanted to define methods out-of-line to be called like
S(some, arguments, of, various, types)
, how would I define the methods?
For S(T&)
, I just do
template <typename T>
S<T>::S(T&){ /* code */ }
, but If I try and do
template<typename T, typename... Ts>
S<T>::S(Ts&&...){ /* code */ }
then it gives me an error: 'too many template parameters in template redeclaration'.
Removing , typename... Ts
results in an error about Ts
not being defined.
What is the correct syntax to write the body of a method outside of the class/struct when there are additional template arguments for the method?
question from:
https://stackoverflow.com/questions/65935185/adding-additional-template-arguments-to-a-method-of-a-class-which-is-already-tem 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…