c++ - compile error for boost::date_time::days_until_weekday -
i'm toying around boost::date_time
. while doing so, came upon days_until_weekday
(documentation link) function appears highly useful me. unfortunately, compile time error following snippet
date f(date d){ return next_weekday(d, boost::date_time::weekdays::friday); }
reading
> in file included > /usr/include/boost/date_time/gregorian/gregorian_types.hpp:25:0, > /usr/include/boost/date_time/posix_time/posix_time_config.hpp:18, > /usr/include/boost/date_time/posix_time/posix_time_system.hpp:13, > /usr/include/boost/date_time/posix_time/ptime.hpp:12, > /usr/include/boost/date_time/posix_time/posix_time.hpp:15, > prog.cpp:3: /usr/include/boost/date_time/date_generators.hpp: in instantiation of > 'typename date_type::duration_type > boost::date_time::days_until_weekday(const date_type&, const > weekday_type&) [with date_type = boost::gregorian::date; weekday_type > = boost::date_time::weekdays; typename date_type::duration_type = boost::gregorian::date_duration]': > /usr/include/boost/date_time/date_generators.hpp:488:34: required > 'date_type boost::date_time::next_weekday(const date_type&, const > weekday_type&) [with date_type = boost::gregorian::date; weekday_type > = boost::date_time::weekdays]' prog.cpp:11:67: required here /usr/include/boost/date_time/date_generators.hpp:452:37: error: > request member 'as_number' in 'wd', of non-class type > 'const boost::date_time::weekdays' > duration_type dd(wd.as_number() - d.day_of_week().as_number());
go here paste of code.
as snippet causing error short, i'm out of ideas fix this.
by way, i'm on boost 1.60.0 using clang 3.7.0.
you need convert date_time enum object matches interface expected weekday_type passed function. use greg_weekday function you, eg:
return next_weekday(d, boost::gregorian::greg_weekday(boost::date_time::friday));
that compiles me under vs2015 , boost 1.53.
a link documentation function: greg_weekday
Comments
Post a Comment