[serialization] versioning for class nested within template class

Hi folks, I am having trouble incrementing the serialization version of a regular class nested within a template class. I'm not sure if the problem is with boost or with my own understanding of the issue. My code looks like: ============================== template <typename A, typename B> struct Foo { struct Bar { int data1; int data2; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, unsigned int version) { ar & data1; if (version >= 2) { ar & data2; } else { data2 = 0; } } }; }; ============================== My attempt at setting the version looks like: ============================== namespace boost { namespace serialization { template <typename A, typename B> struct version<typename Foo<A, B>::Bar> { BOOST_STATIC_CONSTANT(unsigned int, value = 2); }; } // namespace serialization } // namespace boost ============================== However, g++ gives an error: ============================== main.cpp:31:8: error: template parameters not used in partial specialization: main.cpp:31:8: error: ‘A’ main.cpp:31:8: error: ‘B’ ============================== Strangely, clang 3.0 compiles the code but issues some warnings: ============================== main.cpp:31:8: warning: class template partial specialization contains template parameters that can not be deduced; this partial specialization will never be used struct version<typename Foo<A, B>::Bar> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:30:20: note: non-deducible template parameter 'A' template <typename A, typename B> ^ main.cpp:30:32: note: non-deducible template parameter 'B' template <typename A, typename B> ^ 1 warning generated. ============================== I'd appreciate any pointers! Thanks, -Gabe
participants (1)
-
Gabriel Redner