inline std::ostream& operator<<(std::ostream& os,const measurement<Y>& val) { boost::io::ios_precision_saver precision_saver(os); boost::io::ios_flags_saver flags_saver(os); os << val.value() << "(+/-" << val.uncertainty() << ")"; return os; }
std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, process::id const& pid) { if (strm.good()) { io::ios_flags_saver flags_saver(strm, std::ios_base::hex | std::ios_base::showbase); // The width is set calculated to accommodate pid in hex + "0x" prefix io::ios_width_saver width_saver(strm, static_cast< std::streamsize >(pid_size * 2 + 2)); io::basic_ios_fill_saver< CharT, TraitsT > fill_saver(strm, static_cast< CharT >('0')); strm << static_cast< uint_t< pid_size * 8 >::least >(pid.native_id()); } return strm; }
std::basic_ostream<ch, char_traits>& operator<<(std::basic_ostream<ch, char_traits> &os, uuid const& u) { io::ios_flags_saver flags_saver(os); io::basic_ios_fill_saver<ch, char_traits> fill_saver(os); const typename std::basic_ostream<ch, char_traits>::sentry ok(os); if (ok) { const std::streamsize width = os.width(0); const std::streamsize uuid_width = 36; const std::ios_base::fmtflags flags = os.flags(); const typename std::basic_ios<ch, char_traits>::char_type fill = os.fill(); if (flags & (std::ios_base::right | std::ios_base::internal)) { for (std::streamsize i=uuid_width; i<width; i++) { os << fill; } } os << std::hex << std::right; os.fill(os.widen('0')); std::size_t i=0; for (uuid::const_iterator i_data = u.begin(); i_data!=u.end(); ++i_data, ++i) { os.width(2); os << static_cast<unsigned int>(*i_data); if (i == 3 || i == 5 || i == 7 || i == 9) { os << os.widen('-'); } } if (flags & std::ios_base::left) { for (std::streamsize s=uuid_width; s<width; s++) { os << fill; } } os.width(0); //used the width so reset it } return os; }
std::basic_ostream<ch, char_traits>& operator<<(std::basic_ostream<ch, char_traits> &os, uuid const& u) { io::ios_flags_saver flags_saver(os); io::ios_width_saver width_saver(os); io::basic_ios_fill_saver<ch, char_traits> fill_saver(os); const typename std::basic_ostream<ch, char_traits>::sentry ok(os); if (ok) { os << std::hex; os.fill(os.widen('0')); std::size_t i=0; for (uuid::const_iterator i_data = u.begin(); i_data!=u.end(); ++i_data, ++i) { os.width(2); os << static_cast<unsigned int>(*i_data); if (i == 3 || i == 5 || i == 7 || i == 9) { os << os.widen('-'); } } } return os; }
inline std::basic_ostream<Char,Traits>& operator<<(std::basic_ostream<Char,Traits>& os,const physical_constant<Y>& val) { boost::io::ios_precision_saver precision_saver(os); //boost::io::ios_width_saver width_saver(os); boost::io::ios_flags_saver flags_saver(os); //os << std::setw(21); typedef typename Y::value_type value_type; if (val.uncertainty() > value_type()) { const double relative_uncertainty = std::abs(val.uncertainty()/val.value()); const double exponent = std::log10(relative_uncertainty); const long digits_of_precision = static_cast<long>(std::ceil(std::abs(exponent)))+3; // should try to replicate NIST CODATA syntax os << std::setprecision(digits_of_precision) //<< std::setw(digits_of_precision+8) //<< std::scientific << val.value(); // << long(10*(relative_uncertainty/std::pow(Y(10),Y(exponent)))); os << " (rel. unc. = " << std::setprecision(1) //<< std::setw(7) << std::scientific << relative_uncertainty << ")"; } else { os << val.value() << " (exact)"; } return os; }