Hello.
I recently try to use boost.Serialization and it works fine until i
try to serialize a string pointer. With a string pointer, the compiler
(gcc 4.4.1) can't resolve a type and print the error: "error: ‘struct
std::basic_string
’ has no member named ‘serialize’"
Here a schoolish example that fails to compile:
______________________________________________________
#include
#include
#include
#include <fstream>
#include <string>
int main()
{
std::string* s=new std::string("some text");
std::ofstream of("file.txt");
{
boost::archive::text_oarchive oa(of);
// write class instance to archive
oa << s;
// archive and stream closed when destructors are called
}
delete s;
return 0;
}
__________________________________________________________
and the gcc output is:
-------------- Build: Debug in Boost_Serialize_Test ---------------
Compiling: main.cpp
In file included from /usr/include/boost/serialization/split_member.hpp:23,
from /usr/include/boost/serialization/nvp.hpp:33,
from /usr/include/boost/serialization/serialization.hpp:17,
from /usr/include/boost/archive/detail/oserializer.hpp:61,
from /usr/include/boost/archive/detail/interface_oarchive.hpp:24,
from /usr/include/boost/archive/detail/common_oarchive.hpp:20,
from /usr/include/boost/archive/basic_text_oarchive.hpp:32,
from /usr/include/boost/archive/text_oarchive.hpp:31,
from /.../main.cpp:2:
/usr/include/boost/serialization/access.hpp: In static member function
‘static void boost::serialization::access::serialize(Archive&, T&,
unsigned int) [with Archive = boost::archive::text_oarchive, T =
std::basic_string
]’:
/usr/include/boost/serialization/serialization.hpp:74: instantiated
from ‘void boost::serialization::serialize(Archive&, T&, unsigned int)
[with Archive = boost::archive::text_oarchive, T =
std::basic_string::save_object_data(boost::archive::detail::basic_oarchive&, const
void*) const [with Archive = boost::archive::text_oarchive, T =
std::basic_string
I also tried this one codepad. you could see the result here:
http://codepad.org/QnR0mMVs
I don't know if it's an issue or if i'm using serialize the wrong way
but i would need to serialize strings pointers.
Best regards
Mocramis