【发布时间】:2012-04-11 15:28:26
【问题描述】:
#include "boost/date_time/gregorian/gregorian.hpp"
int main()
{
boost::gregorian::greg_weekday dWeek(boost::date_time::Wednesday);
//Code One
// warning C4482: nonstandard extension used: enum 'boost::date_time::weekdays' used in qualified name
if (dWeek.as_enum()==boost::gregorian::greg_weekday::weekday_enum::Wednesday)
{
std::cout << "Today is Wednesday" << std::endl;
}
//class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
//public:
// typedef boost::date_time::weekdays weekday_enum;
//Code Two
if (dWeek.as_enum()==boost::date_time::Wednesday)
{
std::cout << "Today is Wednesday" << std::endl;
}
}
问题> 我见过大量使用Code One 来比较boost::date_time 的代码。基于 C++ 标准,枚举的使用是不正确的。我提供了一个代码二的解决方案。
谁能给我快速看看,看看它是否是正确的比较方法?
谢谢
【问题讨论】:
标签: c++ boost boost-date-time