[ros-users] bug in operator<< for ros::Time

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: ros-users
Subject: [ros-users] bug in operator<< for ros::Time
Hi,

I noticed that all space created with setw in an ostream gets filled zeros
after a ros::Time object has been printed in the ostream.

A patch is availble in the following ticket:
https://code.ros.org/trac/ros/ticket/3693

It just resets the fill caracter to space after the time is printed:

--- time.cpp.original   2011-09-28 16:48:45.000000000 +0200
+++ time.cpp    2011-09-28 16:41:41.000000000 +0200
@@ -311,13 +311,13 @@


   std::ostream& operator<<(std::ostream& os, const Time &rhs)
   {
-    os << rhs.sec << "." << std::setw(9) << std::setfill('0') << rhs.nsec;
+    os << rhs.sec << "." << std::setw(9) << std::setfill('0') << 
rhs.nsec<<std::setfill(' ');
     return os;
   }


   std::ostream& operator<<(std::ostream& os, const Duration& rhs)
   {
-    os << rhs.sec << "." << std::setw(9) << std::setfill('0') << rhs.nsec;
+    os << rhs.sec << "." << std::setw(9) << std::setfill('0') << 
rhs.nsec<<std::setfill(' ');
     return os;
   }



-- Ruben