Boost::Serialize, serializing std::basic_string

I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error: "Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109" I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it? /Jacob Holm

are you including "boost/serialization/string.hpp" ? Robert Ramey "Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810290613i675e7db7h7d54cb3d1bfbe038@mail.gmail.com... I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error: "Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109" I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it? /Jacob Holm ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Yes I am. /Jacob Holm On Wed, Oct 29, 2008 at 6:01 PM, Robert Ramey <ramey@rrsd.com> wrote:
are you including "boost/serialization/string.hpp" ?
Robert Ramey
"Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810290613i675e7db7h7d54cb3d1bfbe038@mail.gmail.com...
I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error:
"Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109"
I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it?
/Jacob Holm
------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

There are several tests in the library which use std::string and std::wstring. Do these compile? string and wstring are typedefs for basic_string<char, ..> and basic_string<wchar,..>. If you use basic_string<my_type, ....> you might need in explicitly instantiated something. Look at how serialization of std:string is implemented/instantiated. Robert Ramey "Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810300008u25bd7d4eua326fd84ece93a69@mail.gmail.com... Yes I am. /Jacob Holm On Wed, Oct 29, 2008 at 6:01 PM, Robert Ramey <ramey@rrsd.com> wrote: are you including "boost/serialization/string.hpp" ? Robert Ramey "Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810290613i675e7db7h7d54cb3d1bfbe038@mail.gmail.com... I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error: "Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109" I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it? /Jacob Holm -------------------------------------------------------------------------- _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

I have tried string, and that works fine. I'll take a look again at the implementation. Thanks! /Jacob Holm* * On Thu, Oct 30, 2008 at 6:29 PM, Robert Ramey <ramey@rrsd.com> wrote:
There are several tests in the library which use std::string and std::wstring.
Do these compile?
string and wstring are typedefs for basic_string<char, ..> and basic_string<wchar,..>.
If you use basic_string<my_type, ....> you might need in explicitly instantiated something. Look at how serialization of std:string is implemented/instantiated.
Robert Ramey
"Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810300008u25bd7d4eua326fd84ece93a69@mail.gmail.com...
Yes I am.
/Jacob Holm
On Wed, Oct 29, 2008 at 6:01 PM, Robert Ramey <ramey@rrsd.com> wrote:
are you including "boost/serialization/string.hpp" ?
Robert Ramey
"Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810290613i675e7db7h7d54cb3d1bfbe038@mail.gmail.com...
I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error:
"Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109"
I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it?
/Jacob Holm
------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

If I pass "basic_string<char>", with the default allocator, it works fine. But if I pass it with my own allocator it fails. /Jacob Holm On Fri, Oct 31, 2008 at 8:07 AM, Jacob Holm <jacobholm@gmail.com> wrote:
I have tried string, and that works fine. I'll take a look again at the implementation. Thanks!
/Jacob Holm*
*
On Thu, Oct 30, 2008 at 6:29 PM, Robert Ramey <ramey@rrsd.com> wrote:
There are several tests in the library which use std::string and std::wstring.
Do these compile?
string and wstring are typedefs for basic_string<char, ..> and basic_string<wchar,..>.
If you use basic_string<my_type, ....> you might need in explicitly instantiated something. Look at how serialization of std:string is implemented/instantiated.
Robert Ramey
"Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810300008u25bd7d4eua326fd84ece93a69@mail.gmail.com...
Yes I am.
/Jacob Holm
On Wed, Oct 29, 2008 at 6:01 PM, Robert Ramey <ramey@rrsd.com> wrote:
are you including "boost/serialization/string.hpp" ?
Robert Ramey
"Jacob Holm" <jacobholm@gmail.com> wrote in message news:94342b580810290613i675e7db7h7d54cb3d1bfbe038@mail.gmail.com...
I have a variable which is a basic_string, as I want my own allocator assigned to it. This gives me the following compiler error:
"Error 3 error C2039: 'serialize' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' ...\boost\serialization\access.hpp 109"
I have searched around for this error but have not been able to find a solution. It would be possible to just pass a vector with chars in it, but basic_string is preferred. Has anyone else had this problem and maybe managed to solve it?
/Jacob Holm
------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

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

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
participants (2)
-
Jacob Holm
-
Robert Ramey