Difficulties with templated functions in templated classes?

The types have to match in both the declaration and definition of func So in the class definition you must declare func as: template typename std::enable_if 1)>::type __func(const char* delim) (This is equivalent to using std::enable_if 1), void as the second template parameter defaults to void ) The reason for this restriction has to do with template specializations. And in fact since you're using std::enable_if you're relying on those specializations as std::enable_if::type which doesn't exist, and hence is invalid (and is then removed via SFINAE).

The types have to match in both the declaration and definition of __func. So in the class definition you must declare __func as: template typename std::enable_if 1)>::type __func(const char* delim); (This is equivalent to using std::enable_if 1), void> as the second template parameter defaults to void. ) The reason for this restriction has to do with template specializations.

And in fact since you're using std::enable_if you're relying on those specializations as std::enable_if is a specialization. Note also the mismatch in the case of __func which doesn't have return type void. It 'has' return type std::enable_if::type, which doesn't exist, and hence is invalid (and is then removed via SFINAE).

Beat me to it! :-) +1 for the nice explanation. – Kerrek SB Oct 11 at 3:24 Thanks, it worked once I prototyped both of the cases exactly for __func.

– Jason Iverson Oct 11 at 3:29.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions