Anyone knows how I can fix this Cppcheck syntax error (no more information than "syntax error") or if it is a false positive (maybe due to options used), I looked at template tutorials and documentations and didn't find any similar usage, the code is:
template<typename T>
template<class Archive> // Here is the Cppcheck syntax error
void MyItemContainer<T>::serialize(Archive & ar, const unsigned int version)
{
....
}
I'm using :
Thanks
This looks to be a problem/false positive with CppCheck. The code uses the correct syntax to define a templated (on Archive
) member function of a templated (on T
) class. The use of class
or typename
in the template signature makes no semantic difference here (but maybe CppCheck stumbles over that? Something to try...).
It could be that some preceding code is invalid and causes a syntax error in this location, but that seems pretty unlikely.
I can't find any useful mention of the word "template" in the manual. But given that CppCheck is still actively developed, you could consider building a small code sample reproducing this problem and submitting it to their bug tracker at https://trac.cppcheck.net/.