|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2006-09-16 02:42:25
Which version of boost is being used here? export in HEAD is difffernent
from that in boost 1.34, 1.33, etc
so we need to know in order to address this.
Robert Ramey
Neal Becker wrote:
> Can anyone see what's wrong with this example?
>
> #include <stdexcept>
> #include <boost/shared_ptr.hpp>
> #include <boost/serialization/split_member.hpp>
> #include <boost/serialization/nvp.hpp>
> #include <boost/serialization/shared_ptr.hpp>
>
> template<typename value_t>
> struct overflow_policy_base {
> overflow_policy_base (value_t _min, value_t _max) :
> min (_min), max (_max) {}
> virtual value_t apply (value_t) = 0;
> // virtual value_t apply (value_t);
> value_t min, max;
>
> friend class boost::serialization::access;
>
> template<class Archive>
> inline void serialize (Archive &ar, const unsigned int) {
> ar & this->min;
> ar & this->max;
> }
> };
>
> template<typename value_t>
> struct limit_policy : public overflow_policy_base<value_t> {
> limit_policy (value_t _min, value_t _max) :
> overflow_policy_base<value_t> (_min, _max) {}
>
> virtual value_t apply (value_t x) {
> if (x > this->max)
> return this->max;
> else if (x < this->min)
> return this->min;
> else
> return x;
> }
>
> template<class Archive>
> inline void serialize (Archive &ar, const unsigned int) {
> ar &
> boost::serialization::base_object<overflow_policy_base<value_t>
> >(*this); } };
>
> template<typename value_t>
> struct throw_policy : public overflow_policy_base<value_t> {
> throw_policy (value_t _min, value_t _max) :
> overflow_policy_base<value_t> (_min, _max) {}
>
> virtual value_t apply (value_t x) {
> if (x > this->max or x < this->min)
> throw std::runtime_error ("Histogram value out of range");
> else
> return x;
> }
>
> template<class Archive>
> inline void serialize (Archive &ar, const unsigned int) {
> ar &
> boost::serialization::base_object<overflow_policy_base<value_t>
> >(*this); } };
>
> #include <boost/serialization/export.hpp>
> BOOST_SERIALIZATION_SHARED_PTR (limit_policy<double>)
> BOOST_CLASS_EXPORT_GUID (limit_policy<double>,
> "limit_policy<double>")
>
> g++ -I /usr/local/src/boost.cvs -xc++ -fsyntax-only test.hpp
> /usr/local/src/boost.cvs/boost/serialization/type_info_implementation.hpp:
> In instantiation of
> 'boost::serialization::type_info_implementation<limit_policy<double>
> >': /usr/local/src/boost.cvs/boost/serialization/export.hpp:76:
> instantiated from
> 'boost::archive::detail::guid_initializer<limit_policy<double> >'
> test.hpp:64: instantiated from here
> /usr/local/src/boost.cvs/boost/serialization/type_info_implementation.hpp:50:
> error: invalid use of undefined type 'struct
> boost::serialization::extended_type_info_impl<limit_policy<double> >'
> /usr/local/src/boost.cvs/boost/serialization/traits.hpp:42: error:
> declaration of 'struct
> boost::serialization::extended_type_info_impl<limit_policy<double> >'
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk