Joh*_*lom 1 c++ boost boost-date-time
我正在missing template arguments编译一个简单的日期解析测试使用boost,这是代码:
#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");
Run Code Online (Sandbox Code Playgroud)
并且编译器抱怨
error: missing template arguments before ‘test’
boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");
我不明白我应该提供什么模板参数或者为什么我应该首先提供模板参数.对我来说似乎有点太多锅炉板代码:)
它应该是boost::gregorian::date代替boost::date_time::date.除此之外,你可以使用
auto test = boost::gregorian::from_us_string("07-Sep-2010");
Run Code Online (Sandbox Code Playgroud)
如果您使用的是C++ 11.