Boost logo

Boost Users :

Subject: [Boost-users] [Date Time] time_duration Subsecond Truncation After Construction
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2011-04-24 19:08:43


Dear all,
[GCC 4.5.1, MinGW32, WinXPSP3, Boost 1.46.0]
I have a simple templatised class which stores references to the passed timestamps. I also have a helper function to ease some syntax awkwardness as follows:
template<typename Timestamp>
struct Container
{
   Container(const Timestamp& t): t_(t)
   {    cout << "In ctor, t = " << to_simple_string(t)           << ", t_ = " << to_simple_string(t_) << endl;
   }
   template<typename T1, typename T2>
   void f(const T1&, const T2&) const
   {
    cout << "In f(), t_ = " << to_simple_string(t_);
   }

   const Timestamp& t_;
};

template<typename Timestamp>
Container<Timestamp> container(const Timestamp& t) {return Container<Timestamp>(t);}

It happens that, in my release build, the subsecond resolution gets truncated once the passed time duration is stored in my Container. So, for the following code snippet for example
container(milliseconds(400)).f(1.1, 2);
I get the following nonsense output:
In ctor, t = 00:00:00.400000, t_ = 00:00:00.400000
In f(), t_ = 00:00:00

Does anyone here know what's going on?
TIA,--Hossein



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