Boost logo

Boost Users :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2008-06-28 13:25:19


Have you tried making the serialize function non-const as is shown in
the tutorial:

http://www.boost.org/doc/libs/1_35_0/libs/serialization/doc/tutorial.html

Matthias

On 28 Jun 2008, at 14:08, michalurbanski wrote:

> Hi,
>
> I get an error "error: no matching function for call to
> ‘load_wrapper(boost::archive::xml_iarchive&, const float&,
> boost::serialization::is_wrapper<float>" for the code of classes (1)
> and (2). The compiler output is in (3).
>
> The error comes from line "ar & BOOST_SERIALIZATION_NVP(constValue);"
>
> If I comment the line "BOOST_CLASS_EXPORT(ConstCellValueStrategy)"
> the code compiles fine, but while running I get a "terminate called
> after throwing an instance of 'boost::archive::archive_exception'
> what(): unregistered class".
>
> Any ideas what do I do wrong?
>
> Regards,
> MU.
>
>
> -----------------------------------------------------------------------
> Attachment 1, the derived class:
>
> #ifndef CONSTCELLVALUESTRATEGY_HPP_
> #define CONSTCELLVALUESTRATEGY_HPP_
>
> #include <boost/archive/xml_iarchive.hpp>
> #include <boost/archive/xml_oarchive.hpp>
> #include <boost/serialization/array.hpp>
> #include <boost/serialization/export.hpp>
> #include <boost/serialization/nvp.hpp>
>
> #include "CellValueStrategy.hpp"
>
> class ConstCellValueStrategy : public CellValueStrategy {
> friend class boost::serialization::access;
>
> template<class Archive> void serialize(Archive & ar, const unsigned
> int version) const {
> ar & BOOST_SERIALIZATION_NVP(constValue);
> }
>
> float constValue;
>
> inline ConstCellValueStrategy() {}
> public:
> ConstCellValueStrategy(const float &constValue);
> float computeValue(const float& x);
> };
>
> BOOST_CLASS_EXPORT(ConstCellValueStrategy)
>
> #endif /*CONSTCELLVALUESTRATEGY_HPP_*/
>
>
>
> -----------------------------------------------------------------------
> Attachment 2, The base abstract class:
>
> #ifndef CELLVALUESTRATEGY_HPP_
> #define CELLVALUESTRATEGY_HPP_
>
> #include <string>
>
> #include <boost/serialization/is_abstract.hpp>
>
> using namespace std;
>
> class CellValueStrategy {
> public:
> virtual float computeValue(const float& x) = 0;
> virtual ~CellValueStrategy() {};
> };
>
> BOOST_IS_ABSTRACT(CellValueStrategy)
>
> #endif /*CELLVALUESTRATEGY_HPP_*/
>
>
>
> -----------------------------------------------------------------------
> Attachment 3, the compilet output:
>
> Invoking: GCC C++ Compiler
> g++ -Isrc -I/usr/local/include/boost-1_35 -I../src -I../srcUTIL -I../
> srcGUI -I../srcCNN -IsrcUTIL -IsrcGUI -IsrcCNN -O0 -msse -g3 -pg -
> Wall -pg -c -fmessage-length=0 -ansi -pedantic -DPNG_NO_MMX_CODE -I/
> usr/include/gtkmm-2.4 -I/usr/lib/gtkmm-2.4/include -I/usr/include/
> glibmm-2.4 -I/usr/lib/glibmm-2.4/include -I/usr/include/gdkmm-2.4 -I/
> usr/lib/gdkmm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/include/
> atkmm-1.6 -I/usr/include/gtk-2.0 -I/usr/include/sigc++-2.0 -I/usr/
> lib/sigc++-2.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/
> include -I/usr/lib/gtk-2.0/include -I/usr/include/cairomm-1.0 -I/usr/
> include/pango-1.0 -I/usr/include/cairo -I/usr/include/freetype2 -I/
> usr/include/libpng12 -I/usr/include/atk-1.0 -MMD -MP -MF"srcUTIL/
> ConstCellValueStrategy.d" -MT"srcUTIL/ConstCellValueStrategy.d" -
> o"srcUTIL/ConstCellValueStrategy.o" "../srcUTIL/
> ConstCellValueStrategy.cpp"
> /usr/local/include/boost-1_35/boost/archive/detail/iserializer.hpp:
> In function ‘void boost::archive::load(Archive&, const T&) [with
> Archive = boost::archive::xml_iarchive, T = float]’:
> /usr/local/include/boost-1_35/boost/archive/detail/
> common_iarchive.hpp:59: instantiated from ‘void
> boost::archive::detail::common_iarchive<Archive>::load_override(T&,
> int) [with T = const float, Archive = boost::archive::xml_iarchive]’
> /usr/local/include/boost-1_35/boost/archive/basic_xml_iarchive.hpp:
> 81: instantiated from ‘void
> boost::archive::basic_xml_iarchive<Archive>::load_override(const
> boost::serialization::nvp<T>&, int) [with T = const float, Archive =
> boost::archive::xml_iarchive]’
> /usr/local/include/boost-1_35/boost/archive/xml_iarchive.hpp:74:
> instantiated from ‘void
> boost::archive::xml_iarchive_impl<Archive>::load_override(T&, int)
> [with T = const boost::serialization::nvp<const float>, Archive =
> boost::archive::xml_iarchive]’
> /usr/local/include/boost-1_35/boost/archive/detail/
> interface_iarchive.hpp:63: instantiated from ‘Archive&
> boost::archive::detail::interface_iarchive<Archive>::operator>>(T&)
> [with T = const boost::serialization::nvp<const float>, Archive =
> boost::archive::xml_iarchive]’
> /usr/local/include/boost-1_35/boost/archive/detail/
> interface_iarchive.hpp:70: instantiated from ‘Archive&
> boost::archive::detail::interface_iarchive<Archive>::operator&(T&)
> [with T = const boost::serialization::nvp<const float>, Archive =
> boost::archive::xml_iarchive]’
> ../srcUTIL/ConstCellValueStrategy.hpp:16: instantiated from ‘void
> ConstCellValueStrategy::serialize(Archive&, unsigned int) const
> [with Archive = boost::archive::xml_iarchive]’
> /usr/local/include/boost-1_35/boost/serialization/access.hpp:109:
> instantiated from ‘static void
> boost::serialization::access::serialize(Archive&, T&, unsigned int)
> [with Archive = boost::archive::xml_iarchive, T =
> ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/serialization.hpp:
> 81: instantiated from ‘void
> boost::serialization::serialize(Archive&, T&, unsigned int) [with
> Archive = boost::archive::xml_iarchive, T = ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/serialization.hpp:
> 140: instantiated from ‘void
> boost::serialization::serialize_adl(Archive&, T&, unsigned int)
> [with Archive = boost::archive::xml_iarchive, T =
> ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/archive/detail/iserializer.hpp:
> 314: instantiated from
> ‘boost::archive::detail::pointer_iserializer<Archive,
> T>::pointer_iserializer() [with Archive =
> boost::archive::xml_iarchive, T = ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/archive/detail/
> dynamically_initialized.hpp:39: instantiated from ‘static T&
> boost::archive::detail::dynamically_initialized<T>::get_instance()
> [with T =
> boost
> ::archive::detail::pointer_iserializer<boost::archive::xml_iarchive,
> ConstCellValueStrategy>]’
> /usr/local/include/boost-1_35/boost/archive/detail/
> dynamically_initialized.hpp:33: instantiated from
> ‘boost
> ::archive::detail::pointer_iserializer<boost::archive::xml_iarchive,
> ConstCellValueStrategy>&
> boost
> ::archive
> ::detail
> ::dynamically_initialized
> <
> boost
> ::archive::detail::pointer_iserializer<boost::archive::xml_iarchive,
> ConstCellValueStrategy> >::instance’
> /usr/local/include/boost-1_35/boost/archive/detail/iserializer.hpp:
> 330: instantiated from ‘static const
> boost::archive::detail::pointer_iserializer<Archive, T>&
> boost::archive::detail::pointer_iserializer<Archive,
> T>::get_instance() [with Archive = boost::archive::xml_iarchive, T =
> ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/export.hpp:59:
> instantiated from ‘static const
> boost::archive::detail::basic_pointer_iserializer&
> boost::archive::detail::export_impl<Archive,
> Serializable>::enable_load(mpl_::true_) [with Archive =
> boost::archive::xml_iarchive, Serializable = ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/export.hpp:138:
> instantiated from ‘static void
> boost::archive::detail::ptr_serialization_support<Archive,
> Serializable>::instantiate() [with Archive =
> boost::archive::xml_iarchive, Serializable = ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/export.hpp:125:
> instantiated from
> ‘boost
> ::archive
> ::detail::ptr_serialization_support<boost::archive::xml_iarchive,
> ConstCellValueStrategy>’
> /usr/local/include/boost-1_35/boost/archive/detail/
> register_archive.hpp:21: instantiated from
> ‘boost
> ::archive
> ::detail::_ptr_serialization_support<boost::archive::xml_iarchive,
> ConstCellValueStrategy>’
> /usr/local/include/boost-1_35/boost/serialization/export.hpp:101:
> instantiated from
> ‘boost::archive::detail::guid_initializer<T>::guid_initializer(const
> char*) [with T = ConstCellValueStrategy]’
> /usr/local/include/boost-1_35/boost/serialization/export.hpp:84:
> instantiated from ‘static const
> boost::archive::detail::guid_initializer<T>&
> boost::archive::detail::guid_initializer<T>::get_instance(const
> char*) [with T = ConstCellValueStrategy]’
> ../srcUTIL/ConstCellValueStrategy.hpp:27: instantiated from here
> /usr/local/include/boost-1_35/boost/archive/detail/iserializer.hpp:
> 589: error: no matching function for call to
> ‘load_wrapper(boost::archive::xml_iarchive&, const float&,
> boost::serialization::is_wrapper<float>)’
> make: *** [srcUTIL/ConstCellValueStrategy.o] Error 1
> make: *** Waiting for unfinished jobs....
> Finished building: ../srcGUI/CNNMainWindow.cpp
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


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