b) if it is possible, what is the correct syntax for the definition of this function?
c) if it is possible to do so, is it possible to specialize this method?
I have google searched a bit, however with no luck. Any advice would be appreciated.
Thanks. That being said, is it possible to specialize the function template which in this case is operator()?
Additionally, I am thinking I should just overload the templated method instead of specializing it. How would the two differ, and is there a rule of thumb to use one or the other?
template <typename T>
struct S
{
template <typename V>
struct S2
{
voidoperator()(S& s, V i)
{
/* general code */
}
};
template <>
struct S2<T>
{
voidoperator()(S& s, T i)
{
/* specialized code for V = T */
}
};
template <typename V>
friendstruct S2; // use this if you want to access private members of S in S2
template <typename V>
voidoperator()(V i)
{
S2<V>()(*this, i);
}
};
The friend declaration make struct S2 behave exactly as if it is a method of S since it can access S members.