The following error arises when I try to compile [url=http://sourceforge.net/projects/tinybind/]tinybind, an apparently unsupported code project. (A compile-killing bug reported a year ago has gone unanswered.) So I'm looking for help outside.
Apparently VC2003 introduced this error, C2768, and VC2005 made matters worse. Anyway, here's the template definition:
-
template<class T>
-
TiXmlBinding<T> const *
-
GetTiXmlBinding( T const &, IdentityBase );
-
Here's a target class:
- struct MyData
-
{
-
int i;
-
double d;
-
char const * s;
-
std::vector<int> vec;
-
int iref;
-
-
void setIntvalue( int in ) {
-
i = in;
-
}
-
int intvalue() {
-
return i;
-
}
-
-
int & getIRef() {
-
return iref;
-
}
-
};
-
And here's the template instantiation that gets the C2768 error, just before the function body:
-
TiXmlBinding<MyData> const *
-
GetTiXmlBinding<MyData>( MyData const &, Identity<MyData> )
-
{
-
static MemberTiXmlBinding<MyData> binding;
-
if( binding.empty() ) {
-
binding.AddMember( "ITAG", Member(&MyData::i) );
-
binding.AddMember( "ITAGGETSET", Member(&MyData::intvalue, &MyData::setIntvalue) );
-
binding.AddMember( "DTAG", Member(&MyData::d) );
-
binding.AddMember( "STAG", Member(&MyData::s) );
-
binding.AddMember( "VEC", Member(&MyData::vec) );
-
binding.AddMember( "IREF", Member(&MyData::getIRef) );
-
}
-
return &binding;
-
}
Anybody understand the complaint and how it might be mended? Microsoft's doc says put "template <>" in front of the function definition; that helps in some cases but not this one.
(I'm not showing you the lengthy MemberTiXmlBinding class, because it seems pretty clear this is an issue of the function header, not its body. Right?)