-
Notifications
You must be signed in to change notification settings - Fork 761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::wstring #309
Comments
This is not yet supported, see #95 |
Is there a workaround? I'm trying to integrate cereal with legacy code, and they use wstring for everything. |
std::wstring only works in the binary output/input archive. That was how I worked around it. |
Next code allows to solve this problem (but it would work for std::wstring only, not for std::basic_string<wchar_t, custom...>): namespace cereal
{
template<class A>
std::string CEREAL_SAVE_MINIMAL_FUNCTION_NAME( A const &, const std::wstring &in )
{
return boost::locale::conv::utf_to_utf<char>( in );
}
template<class A>
void CEREAL_LOAD_MINIMAL_FUNCTION_NAME( A const &, std::wstring &out, const std::string &in )
{
out = boost::locale::conv::utf_to_utf<wchar_t>( in );
}
}
CEREAL_SPECIALIZE_FOR_ALL_ARCHIVES( std::wstring, cereal::specialization::non_member_load_save_minimal ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you use serialize wide strings? (http://www.cplusplus.com/reference/string/wstring/)
1>cereal\inc\cereal/archives/json.hpp(879): error C2664: 'void cereal::JSONOutputArchive::saveValue(unsigned long)': cannot convert argument 1 from 'const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>' to 'bool' (compiling source file .cpp)
1> cereal\inc\cereal/archives/json.hpp(879): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called (compiling source file .cpp)
1> cereal\inc\cereal/cereal.hpp(410): note: see reference to function template instantiation 'void cereal::save<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>(cereal::JSONOutputArchive &,const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> &)' being compiled (compiling source file .cpp)
1> cereal\inc\cereal/cereal.hpp(333): note: see reference to function template instantiation 'ArchiveType &cereal::OutputArchive<ArchiveType,0>::processImplstd::wstring,0(const T &)' being compiled
The text was updated successfully, but these errors were encountered: