0
#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;
}
}
問題的枚舉項正確方法>我已經看到了使用一個代碼做boost::date_time
比較萬噸的代碼。基於C++標準,枚舉的用法不正確。我提供了一個解決方案代碼二。指`的boost :: date_time`
有人能給我快看,看看它是否是正確的比較方式嗎?
謝謝
號的boost ::陽曆:: greg_weekday ::週三會導致錯誤C2039:「週三':不是'boost :: gregorian :: greg_weekday' – q0987 2012-04-11 15:43:03
@ q0987的成員抱歉,我的錯,修復了它。我沒有檢查返回什麼類型的as_enum()。 – 2012-04-11 16:13:22