Ticket #9177: basic_text_oprimitive.hpp.patch
File basic_text_oprimitive.hpp.patch, 2.4 KB (added by , 9 years ago) |
---|
-
basic_text_oprimitive.hpp
84 84 85 85 // default saving of primitives. 86 86 template<class T> 87 void stream_maybe_float(const T &t, const mpl::true_&){ 88 // Type appears to report that it is a floating point type: 89 std::ios_base::fmtflags f = os.flags(); 90 std::streamsize p = os.precision(); 91 os << std::setprecision(std::numeric_limits<T>::digits10 + 2) << std::scientific << t; 92 os.flags(f); 93 os.precision(p); 94 } 95 template<class T> 96 void stream_maybe_float(const T &t, const mpl::false_&){ 97 os << t; 98 } 99 template<class T> 87 100 void save(const T &t){ 88 101 if(os.fail()) 89 102 boost::serialization::throw_exception( 90 103 archive_exception(archive_exception::output_stream_error) 91 104 ); 92 os << t; 105 typedef mpl::bool_< 106 is_floating_point<T>::value 107 || (std::numeric_limits<T>::is_specialized && 108 !std::numeric_limits<T>::is_integer && 109 !std::numeric_limits<T>::is_exact && 110 std::numeric_limits<T>::max_exponent) 111 > tag_type; 112 stream_maybe_float(t, tag_type()); 93 113 } 94 114 95 115 ///////////////////////////////////////////////////////// … … 123 143 save(static_cast<int>(t)); 124 144 } 125 145 #endif 126 void save(const float t)127 {128 // must be a user mistake - can't serialize un-initialized data129 if(os.fail())130 boost::serialization::throw_exception(131 archive_exception(archive_exception::output_stream_error)132 );133 os << std::setprecision(std::numeric_limits<float>::digits10 + 2);134 os << t;135 }136 void save(const double t)137 {138 // must be a user mistake - can't serialize un-initialized data139 if(os.fail())140 boost::serialization::throw_exception(141 archive_exception(archive_exception::output_stream_error)142 );143 os << std::setprecision(std::numeric_limits<double>::digits10 + 2);144 os << t;145 }146 146 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY()) 147 147 basic_text_oprimitive(OStream & os, bool no_codecvt); 148 148 BOOST_ARCHIVE_OR_WARCHIVE_DECL(BOOST_PP_EMPTY())