Ticket #7261: io.hpp.diff
File io.hpp.diff, 1.8 KB (added by , 10 years ago) |
---|
-
.hpp
old new 1041 1041 template<class Char, class Traits, class Unit, class T> 1042 1042 inline std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, const quantity<Unit, T>& q) 1043 1043 { 1044 std::ostringstream oss; 1045 // if os.width() > 0 then need to build a single string of the quantity 1046 // with the width specified using ostringstream 1047 // (otherwise, outputing value and unit (perhaps autoprefixed to km) 1048 // severally would overflow the width). 1049 // else output directly to ostream os. 1050 1044 1051 if (units::get_autoprefix(os) == autoprefix_none) 1045 1052 { 1046 os<< q.value() << ' ' << Unit();1053 ((os.width()> 0) ? oss : os) << q.value() << ' ' << Unit(); 1047 1054 } 1048 1055 else if (units::get_autoprefix(os) == autoprefix_engineering) 1049 1056 { 1050 detail::maybe_print_prefixed<detail::engineering_prefixes>( os, q, detail::test_norm(autoprefix_norm(q.value())));1057 detail::maybe_print_prefixed<detail::engineering_prefixes>(((os.width() > 0) ? oss : os), q, detail::test_norm(autoprefix_norm(q.value()))); 1051 1058 } 1052 1059 else if (units::get_autoprefix(os) == autoprefix_binary) 1053 1060 { 1054 detail::maybe_print_prefixed<detail::binary_prefixes>( os, q, detail::test_norm(autoprefix_norm(q.value())));1061 detail::maybe_print_prefixed<detail::binary_prefixes>(((os.width() > 0) ? oss : os), q, detail::test_norm(autoprefix_norm(q.value()))); 1055 1062 } 1056 1063 else 1057 1064 { 1058 1065 assert(!"Autoprefixing must be one of: no_prefix, engineering_prefix, binary_prefix"); 1059 1066 } 1067 if (os.width() > 0) 1068 { 1069 os << oss.str(); // Would be "" string if oss not used. 1070 } 1071 1060 1072 return(os); 1061 1073 } 1062 1074