#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++ 标准,枚举的使用是不正确的。我提供了一个解决方案,代码二。
有人可以让我快速看一下,看看它是否是正确的比较方法?
谢谢