Boost logo

Boost Users :

From: Jeffrey Holle (jeff.holle_at_[hidden])
Date: 2004-12-03 16:25:55


Just how am I supposed to use a BOOST_STRONG_TYPEDEF produced type?
If I make it the type of the class attribute, I get an error everywhere
that I use it. Usage examples would be helpful. For instance, what does:
   m_pByPointerPrefix = new char[strlen(src.m_pByPointerPrefix)+1];
need to be turned into when m_pByPointerPrefix goes from a "char" to
tracked_char"?

If I only need to introduce tracked_char in the serialize methods, I
need examples of doing this too...

Robert Ramey wrote:
> pointers to primitive objects are not serializable by default. This is
> explained in the document which describes serialization traits. The reason
> for this is
>
> a) suppose one place in the program I serialization a pointer to a float.
> Then addresses of ALLL the floats in the program would end up being
> seriailzed which is probably not what one wants.
>
> The solution is to make a wrapper so the the type has its own class
>
> BOOST_STRONG_TYPEDEF(float, tracked_float)
>
> Then use a tracked_float instead of a normal float where you want to
> serialize it through a pointer.
>
> Note that strings and characters are both considered primitive types in this
> context - I just used float as an example.
>
> This is the second time this question has come up so I guess we need to
> augment the manual and/or include another static assertion in the code.
>
> Good Luck - hope this his helpful
>
> Robert Ramey
>
>
>
> "Jeffrey Holle" <jeff.holle_at_[hidden]> wrote in message
> news:coqcn7$uhv$1_at_sea.gmane.org...
>
>>At this point, the last compilation problem in applying the
>>boost.serialization library to my application has to do with pointers.
>>
>>Specifically, its pointers to std::string and char member attributes.
>>
>>I have other pointer member attributes that compile successfully, but
>>this point to objects that have serialize methods.
>>
>>I have attempted use of register_type and am including
>>"serialization/string.hpp" in the modules that have pointer to string
>>attributes. These actions were not affective.
>>
>>As an example of the type of compilation error, when I uncomment the
>>following attribute's archive attempt:
>> char *m_pByPointerPrefix;
>>I get:
>>
>>/home/jholle/boost_1_32_0/boost/serialization/access.hpp: In static
>>member function `static void
>>boost::serialization::access::serialize(Archive&, T&, unsigned int)
>>[with Archive = boost::archive::binary_iarchive, T = char]':
>>/home/jholle/boost_1_32_0/boost/serialization/serialization.hpp:78:
>>instantiated from `void boost::serialization::serialize(Archive&, T&,
>>unsigned int) [with Archive = boost::archive::binary_iarchive, T = char]'
>>/home/jholle/boost_1_32_0/boost/serialization/serialization.hpp:121:
>>instantiated from `void boost::serialization::serialize_adl(Archive&,
>>T&, unsigned int) [with Archive = boost::archive::binary_iarchive, T =
>>char]'
>>/home/jholle/boost_1_32_0/boost/archive/detail/iserializer.hpp:155:
>>instantiated from `void boost::archive::detail::iserializer<Archive,
>>T>::load_object_data(boost::archive::detail::basic_iarchive&, void*,
>>unsigned int) const [with Archive = boost::archive::binary_iarchive, T =
>>char]'
>>VariableName.cpp:102: instantiated from here
>>/home/jholle/boost_1_32_0/boost/serialization/access.hpp:106: error:
>>request for member `serialize' in `t', which is of non-class type `char'
>>
>>
>>What is the solution to this?


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