boost date missing template arguments before

378 views Asked by At

I'm getting a missing template arguments when compiling a simple date parsing test using boost, here is the code:

#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");

and the compiler complains error: missing template arguments before ‘test’ boost::date_time::date test = boost::gregorian::from_us_string("07-Sep-2010");

I don't understand what template arguments I should provide or why I should do provide template arguments in first place. It seems to be a little to much boiler plate code for my taste:)

1

There are 1 answers

0
m.s. On BEST ANSWER

It should be boost::gregorian::date instead of boost::date_time::date. Aside from that, you could use

auto test = boost::gregorian::from_us_string("07-Sep-2010");

if you are using C++11.