
Robert Ramey wrote:
Johan Råde wrote:
The facets extended_num_put and extended_num_get are never called. Instead std::num_put and std::num_get are called.
Here is my rendition of your test. Note the addition of the archive open flag archive::no_codecvt to inhibit the serialization library from from using its own code convert facet.
#include <sstream> #include "../../../facet/non_finite_num_facets/extended_num_facets.hpp" #include <boost/test/minimal.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> using namespace std; int test_main(int argc, char * argv[]){ stringstream ss; locale old_locale; locale tmp_locale(old_locale, new boost::serialization::extended_num_get<char>); locale new_locale(tmp_locale, new boost::serialization::extended_num_put<char>); ss.imbue(new_locale); double x = std::numeric_limits<double>::infinity(); { boost::archive::text_oarchive oa(ss, boost::archive::no_codecvt); oa & x; } double y; { boost::archive::text_iarchive ia(ss, boost::archive::no_codecvt); ia & y; } BOOST_CHECK(x == y); return 0; }
Thank you Robert. I will update the documentation of the facets, and the regression tests.
A couple of other observations:
this shouldn't be in the serialization namespace - nor should it be in the archive namespace. Its more general - e.g. fixing up lexical_cast and is a "stream" thing not a "serialization" thing.
I agree. I will move the facets to a different namespace, as soon as I know where to move them. To the boost.math library? Or should there be a new boost.facet library? That would be a good home for the utf8 codecvt facet as well. I will soon ask for an informal review of the facets. That could be a good time to discuss that question. --Johan Råde