从时钟获取当前日期

Hel*_*ays 4 c++ boost boost-date-time

我这样做

 boost::gregorian::date current_date(boost::date_time::day_clock::local_day());
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

‘template<class date_type> class boost::date_time::day_clock’ used without template parameters  
Run Code Online (Sandbox Code Playgroud)

我必须做些什么呢?

参考http://www.boost.org/doc/libs/1_47_0/doc/html/date_time/gregorian.html#date_construct_from_clock

ild*_*arn 11

你使用错了day_clock- 改用它:

boost::gregorian::date current_date(boost::gregorian::day_clock::local_day());
Run Code Online (Sandbox Code Playgroud)

day_clockin boost::date_time是一个通用接口(在这种情况下为模板),意味着与外部提供的'date'类型一起使用,并且您不提供该类型.day_clockin boost::gregorian是使用boost::gregorian::date提供的'date'类型的所述接口的typedef .