
Hello, I'm looking on possibility to use std::wstring in serialization. Here is a simple example which I try to compile: #define UNICODE #include <windows.h> #include <assert.h> #include <stdio.h> #include <string> #include <map> #include <iostream> #include <fstream> #include <boost/config.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp> int main() { std::map<std::wstring, std::wstring> t; std::ofstream ofs ("test.dat", std::ios::trunc | std::ios::binary ); boost::archive::binary_oarchive oa(ofs); assert (ofs.good()); t[L"asd"]=L"test"; oa << t; ofs.close(); }; I use latest downloaded boost and mingw 3.4.5. I got such error: c:/boost/boost/serialization/access.hpp: In static member function `static voidboost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_tr aits<wchar_t>, std::allocator<wchar_t> >]': c:/boost/boost/serialization/serialization.hpp:81: instantiated from `void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_ t>, std::allocator<wchar_t> >]' c:/boost/boost/serialization/serialization.hpp:140: instantiated from `void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<w char_t>, std::allocator<wchar_t> >]' c:/boost/boost/archive/detail/oserializer.hpp:151: instantiated from `void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binar y_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >]' test.cpp:96: instantiated from here c:/boost/boost/serialization/access.hpp:109: error: 'struct std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' has no member named 'serialize' So, what the right way to use wstring here? -- My PGP public key: http://yurichev.com/dennis.yurichev.asc

Last I checked, mingw didn't have support for wide characters. Perhaps the boost/config.h needs to be checked. Robert Ramey Hello, I'm looking on possibility to use std::wstring in serialization. Here is a simple example which I try to compile: #define UNICODE #include <windows.h> #include <assert.h> #include <stdio.h> #include <string> #include <map> #include <iostream> #include <fstream> #include <boost/config.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp> int main() { std::map<std::wstring, std::wstring> t; std::ofstream ofs ("test.dat", std::ios::trunc | std::ios::binary ); boost::archive::binary_oarchive oa(ofs); assert (ofs.good()); t[L"asd"]=L"test"; oa << t; ofs.close(); }; I use latest downloaded boost and mingw 3.4.5. I got such error: c:/boost/boost/serialization/access.hpp: In static member function `static voidboost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_tr aits<wchar_t>, std::allocator<wchar_t> >]': c:/boost/boost/serialization/serialization.hpp:81: instantiated from `void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_ t>, std::allocator<wchar_t> >]' c:/boost/boost/serialization/serialization.hpp:140: instantiated from `void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<w char_t>, std::allocator<wchar_t> >]' c:/boost/boost/archive/detail/oserializer.hpp:151: instantiated from `void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binar y_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >]' test.cpp:96: instantiated from here c:/boost/boost/serialization/access.hpp:109: error: 'struct std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' has no member named 'serialize' So, what the right way to use wstring here? -- My PGP public key: http://yurichev.com/dennis.yurichev.ascDennis Yurichev wrote:
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hello Robert, Friday, May 9, 2008, 7:26:50 PM, you wrote:
Last I checked, mingw didn't have support for wide characters. Perhaps the boost/config.h needs to be checked.
Thank you. VC9 working perfectly in my case. -- My PGP public key: http://yurichev.com/dennis.yurichev.asc

Double check the config.h for this compiler/environment to see that wstring is indeed supported on this platform. Robert Ramey Hello, I'm looking on possibility to use std::wstring in serialization. Here is a simple example which I try to compile: #define UNICODE #include <windows.h> #include <assert.h> #include <stdio.h> #include <string> #include <map> #include <iostream> #include <fstream> #include <boost/config.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/map.hpp> #include <boost/serialization/string.hpp> int main() { std::map<std::wstring, std::wstring> t; std::ofstream ofs ("test.dat", std::ios::trunc | std::ios::binary ); boost::archive::binary_oarchive oa(ofs); assert (ofs.good()); t[L"asd"]=L"test"; oa << t; ofs.close(); }; I use latest downloaded boost and mingw 3.4.5. I got such error: c:/boost/boost/serialization/access.hpp: In static member function `static voidboost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_tr aits<wchar_t>, std::allocator<wchar_t> >]': c:/boost/boost/serialization/serialization.hpp:81: instantiated from `void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_ t>, std::allocator<wchar_t> >]' c:/boost/boost/serialization/serialization.hpp:140: instantiated from `void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive, T = std::basic_string<wchar_t, std::char_traits<w char_t>, std::allocator<wchar_t> >]' c:/boost/boost/archive/detail/oserializer.hpp:151: instantiated from `void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binar y_oarchive, T = std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >]' test.cpp:96: instantiated from here c:/boost/boost/serialization/access.hpp:109: error: 'struct std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' has no member named 'serialize' So, what the right way to use wstring here? -- My PGP public key: http://yurichev.com/dennis.yurichev.ascDennis Yurichev wrote:
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Dennis Yurichev
-
Ray Fix
-
Robert Ramey