Boost logo

Boost Users :

From: Andrew McDonald (Andrew.McDonald_at_[hidden])
Date: 2008-07-11 13:11:12


I was wondering why in the archive library the input and output text streams are hardcoded with the boolalpha bit as unset, e.g. (is >> std::noboolalpha;)?

Specifically the code is in the directory: boost_1_35_0/boost/archive/impl/

In basic_text_iprimitive.ipp

template<class IStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_text_iprimitive<IStream>::basic_text_iprimitive(
    IStream &is_,
    bool no_codecvt
) :
    is(is_),
    flags_saver(is_),
    precision_saver(is_),
    archive_locale(NULL),
    locale_saver(is_)
{
    if(! no_codecvt){
        archive_locale.reset(
            add_facet(
                std::locale::classic(),
                new codecvt_null<BOOST_DEDUCED_TYPENAME IStream::char_type>
            )
        );
        is.imbue(* archive_locale);
    }
    is >> std::noboolalpha;
}

and basic_text_oprimitive.ipp

template<class OStream>
BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())
basic_text_oprimitive<OStream>::basic_text_oprimitive(
    OStream & os_,
    bool no_codecvt
) :
    os(os_),
    flags_saver(os_),
    precision_saver(os_),
    archive_locale(NULL),
    locale_saver(os_)
{
    if(! no_codecvt){
        archive_locale.reset(
            add_facet(
                std::locale::classic(),
                new codecvt_null<BOOST_DEDUCED_TYPENAME OStream::char_type>
            )
        );
        os.imbue(* archive_locale);
    }
    os << std::noboolalpha;
}

Andrew McDonald
Software Engineer
 
"Zufall ist nur der Ausdruck unserer Unfähigkeit, den Dingen auf Grund zu kommen" - Albert Einstein


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net