OK I have:
template<typename T>
class Reader
{
class Input
{
template<typename C>
void operator()(C& val) const
{
/* Do Some Work */
}
};
};
Unfortunately the generic version of "Do Some Work" does not work for me. Nor it is easy to modify because it is in the middle of some heavy template meta programming code.
So I though I could specialize the method for my type. So my first step was to try and pull the general method out of the class.
template<typename T>
class Reader
{
class Input
{
template<typename C>
void operator()(C&开发者_开发技巧 val) const;
};
};
template<typename T>
template<typename C>
void typename Reader<T>::Input template operator()<C>(C& val) const // LINE 13
{
/* Do Some Work */
}
Unfortunately I am getting the error:
s.h:13: error: error: expected ‘)’ before ‘&’ token
Just write it like normal
template<typename T>
template<typename C>
void Reader<T>::Input::operator()(C& val) const // LINE 13
{
/* Do Some Work */
}
Defining the generic version out of class doesn't help you with providing special versions of it though, or I do miss the goal of yours here.
I guess it is impossible as it counts as partial function template specialization, which is not allowed. void Reader<T>::Input::operator () (C& int)
has an implicit first argument (the this
pointer) of type Reader<T>::Input *
, hence its signature is in fact void (Reader<T>::Input *, C &)
. You are trying to specify C
, yet not T
.
精彩评论