|
Boost Users : |
Subject: [Boost-users] [serialization] versioning for class nested within template class
From: Gabriel Redner (gredner_at_[hidden])
Date: 2012-12-03 17:51:40
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net