Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2006-08-17 12:40:59


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.
>
> There is a workaround: first construct the stream, then construct the
> archive, and then imbue the stream with the new locale. But that seems
> counter-intuitive.

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;
}

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.

Robert Ramey

>
> --Johan Råde
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk