On 7/4/17 2:48 AM, Elizabeta via Boost-users wrote:
Hi Robert I did template specialization of basic_text_iprimitive::load for double, and it works with visual studio 2010 compiler. Do you see something problematic with this code
namespace boost { namespace archive { template<> template<> void basic_text_iprimitive< std::basic_istream
> >::load<double>(double& t) { if (!is.fail()) { std::wstring s; getline(is, s, L'<'); is.putback(L'<'); int index = s.find(L"IND"); if (index != -1) { t = std::numeric_limits<double>::quiet_NaN(); return; }
index = s.find(L"NAN"); if (index != -1) { t = std::numeric_limits<double>::quiet_NaN(); return; }
index = s.find(L"INF"); if (index != -1) { t = std::numeric_limits<double>::infinity(); return; }
t = std::stod(s); return; }
boost::serialization::throw_exception( archive_exception(archive_exception::input_stream_error) ); } } }
Hmmm - very clever. I have to say the specialization of just one member function is something that would never have occurred to me. I would wonder though. I'm not sure that the Nan literals are standard. I also don't trust them to be portable. Also to me it's a problem with stream i/o rather than serialization itself. So my instinct would have been to maybe make a custom manipulator or something like that. But still, you've got a solution which looks like it will work well for your needs so good luck with this. Robert Ramey