Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-08-03 00:43:38


string is considered a primitive type and therefore not serializable
through a pointer. (shared_ptr<string> contains a pointer to a string.
Look in the documentation for serialization of pointers.

You can address this by wrapping string in another class just
for serialization.

Robert Ramey

Vjekoslav Brajkovic wrote:
> Hi,
>
> I receive a compile time error when I try to serialize
> shared_ptr<string> in my class. Here are the relevant parts of this
> class:
>
> /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
>
> #include <boost/serialization/base_object.hpp>
> #include <boost/serialization/shared_ptr.hpp>
> #include <boost/serialization/string.hpp>
>
> class chunk_data : public chunk_metadata {
>
> public:
>
> chunk_data(std::string s);
>
> chunk_data(
> chunk_metadata metadata,
> boost::shared_ptr<std::string> data_ptr);
>
> chunk_data(
> boost::filesystem::path path,
> chunk_metadata::cuid_type chunk_id);
>
> chunk_data(
> boost::filesystem::path path,
> chunk_metadata::cuid_type chunk_id,
> boost::shared_ptr<std::string> data_ptr);
>
> virtual ~chunk_data();
>
> template <typename Archive>
> void serialize(Archive& ar, const unsigned int version) {
> boost::serialization::base_object<chunk_metadata>(*this);
> ar & data_ptr_;
> }
>
> boost::shared_ptr<std::string> data_ptr_;
> };
>
> /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
>
> And here are the relevant parts from compilation error.
>
> invalid application of â?~sizeofâ?T to incomplete type
> â?~boost::STATIC_ASSERTION_FAILURE<false>â?T
> error: â?~struct std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >â?T has no member named â?~serializeâ?T
>
> I haven't found any relevant hints about this error neither in the
> documentation or on the boost mailing list. Also I've attached the
> compilation log. I would really appreciate any help.
>
> -Vjeko
>
>
>
>> _______________________________________________
>> 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