|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2005-08-04 11:57:16
I believe this is a side effect of our efforts to be sure that the mere
inclusion of a class that includes serialization headers doesn't trigger
(through auto-linking) the requirement for inlcuding a library module.
The idea is that one would never need "void_cast_register<T>" to be
generated unless there is an archive somewhere involved.
So that raises the question of what the context is here. Your test
illustrates the link error but it doesn't illustrate the use case. That is,
what is the context of explicitly invoking void_cast_register without an
archive header present? I'm not saying its wrong. Its just that I don't
see how this comes up.
When we implemented changes which resulted in this symptom - we enivisioned
a pattern of usage like that shown below. In this way, the *.hpp files
could be included in other programs without triggering auto-link and
requiring linking with the boost library to include code that in fact will
never be used. Were we missing something here? What is it?
Robert Ramey
Z.hpp
====
#include <boost/serialization/is_abstract.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/export.hpp>
class Z
...
};
BOOST_IS_ABSTRACT(Z)
A.hpp
====
#include ... // other serialization headers
#include "Z.hpp"
class A : public Z {
A(){
boost::serialization::void_cast_register<A, Z>(0,0);
}
};
BOOST_CLASS_EXPORT(A)
B.hpp
====
#include ... // other serialization headers
#include "Z.hpp"
class B : public Z
{
...
B(){
boost::serialization::void_cast_register<B, Z>(0,0);
}
};
BOOST_CLASS_EXPORT(B)
main.cpp
======
#include <boost/serialization/text_oarchive.hpp>
#include <boost/serialization/text_iarchive.hpp>
#include "Z.hpp"
#include "A.hpp"
#include "B.hpp"
int main(int argc, char* argv[]){
return 0;
}
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