1

I'm trying to use the date/time facilities of the C++ Boost library v1.41. (Note: this is Linux, not Windows; g++ v4.4.7)

Code:

#include <boost/date_time/posix_time/posix_time.hpp>
using boost::posix_time::ptime;
using boost::date_time::microsec_clock;
 :
t1 = (boost::date_time::microsec_clock::local_time()); // line 208

The error:

tom.cpp:208: error: 'template<class time_type> class boost::date_time::microsec_clock' used without template parameters

Now, there's this in boost/date_time/posix_time/posix_time_types.hpp:

#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
  //! A time clock that has a resolution of one microsecond
  /*! \ingroup time_basics
   */
  typedef date_time::microsec_clock<ptime> microsec_clock;
#endif

What I'm concluding is that BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK is undefined, resulting in the typedef never happening, resulting in the reference to "microsec_clock" looking like it needed a template parameter.

As far as I can tell, I'm following the Boost date_time documentation to the letter. Any ideas?

Chap
  • 3,649
  • 2
  • 46
  • 84
  • You could upgrade both `boost` and `g++`. Your versions are quite old! – Basile Starynkevitch Sep 11 '13 at 04:51
  • If that is indeed the problem, I'm out of luck. I may not have this exactly right, but CentOS provides packages of certain levels of software that it "approves": Boost is at its latest approved level, and g++ is at its latest 4.4.* version (and operations is leery to move beyond 4.4). It's out of my hands - I've tried :-/ – Chap Sep 11 '13 at 13:30
  • No, you can install (even inside your `$HOME/software/` directory) your own more recent versions of `boost` and `g++`. – Basile Starynkevitch Sep 11 '13 at 13:32
  • Same problem after migrating from 1.55 to 1.64 . Disapeared after including both headers: #include boost/date_time/posix_time/posix_time.hpp #include boost/date_time/posix_time/posix_time_types.hpp – dE fENDER Jul 20 '17 at 15:31

1 Answers1

0

I have the same problem right now. Yesterday it worked without any problems but today I needed to delete all my compiled libraries and recompile them due to a svn corruption problem. Ever since this error occurred.

The way to fix it is rather simple. Just use

t1 = (boost::posix_time::microsec_clock::local_time());

instead of

t1 = (boost::date_time::microsec_clock::local_time());

This will preset the time type to posix format however it will not fix the initial problem with BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK.

I hope this was of help to you.