I looked up the typedef of string;

typedef basic_string<char, char_traits<char>, allocator<char> >
 string;

Then made my own typedef;

typedef basic_string<char, char_traits<char>, NewAllocator<char> >
 stringWithAllocator;

..and registered this with boost in the string.hpp;

BOOST_CLASS_IMPLEMENTATION(stringWithAllocator, boost::serialization::primitive_type)

Then the code compiles, but serialization does not work. It seems the allocator is part of the object when serialized, and since the allocator has members the size is being calculated wrong. I did a work around using a std::vector<char, NewAllocator<char>>. This is not as smooth, but does the job.

/Jacob Holm

On Fri, Oct 31, 2008 at 6:38 PM, Robert Ramey <ramey@rrsd.com> wrote:
basic_string with your own allocator is not the same type as basic_string
with
the default allocator.

Look at hos serialization of std::string is implemented and make your own
using that as an example.

Robert Ramey



_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users