我在使用boost编译简单的日期解析测试时得到missing template arguments
,这里是代码:
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/gregorian/parsers.hpp"
boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");
并且编译器抱怨
error: missing template arguments before ‘test’
boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");
我不明白我应该提供哪些模板参数,或者为什么我应该首先提供模板参数。根据我的口味,它似乎是一点点锅炉板代码:)
答案 0 :(得分:5)
应该是boost::gregorian::date
而不是boost::date_time::date
。
除此之外,您可以使用
auto test = boost::gregorian::from_us_string("07-Sep-2010");
如果您使用的是C ++ 11。