C++ 引用'boost::date\u time'枚举项的正确方法` #包括“boost/date\u time/gregorian/gregorian.hpp” int main() { boost::gregorian::greg_工作日dWeek(boost::日期时间::周三); //代码一 //警告C4482:使用了非标准扩展:在限定名称中使用了枚举'boost::date\u time::weekdays' if(dWeek.as_enum()==boost::gregorian::greg_weekday::weekday_enum::周三) { 标准::cout
编辑:更正 使用 我没有查看as_enum()返回的类型。修复了它,编译并工作(在MSVC2k10上,Boost 1.48.0自建) EDIT2:你会发现它隐藏在boost/date\u time/gregorian/greg\u facet.hpp中C++ 引用'boost::date\u time'枚举项的正确方法` #包括“boost/date\u time/gregorian/gregorian.hpp” int main() { boost::gregorian::greg_工作日dWeek(boost::日期时间::周三); //代码一 //警告C4482:使用了非标准扩展:在限定名称中使用了枚举'boost::date\u time::weekdays' if(dWeek.as_enum()==boost::gregorian::greg_weekday::weekday_enum::周三) { 标准::cout,c++,boost,boost-date-time,C++,Boost,Boost Date Time,编辑:更正 使用 我没有查看as_enum()返回的类型。修复了它,编译并工作(在MSVC2k10上,Boost 1.48.0自建) EDIT2:你会发现它隐藏在boost/date\u time/gregorian/greg\u facet.hpp中 boost::date_time::Wednesday 无论如何,其余信息的相关部分是有一个boost::date_time::weekdays::周三,但我们去掉了工作日 枚举基本上类似于: namespace boost{ namespac
boost::date_time::Wednesday
无论如何,其余信息的相关部分是有一个boost::date_time::weekdays::周三,但我们去掉了工作日
枚举基本上类似于:
namespace boost{
namespace gregorian{
typedef boost::date_time::weekdays weekday_enum;
}
}
foo不是名称空间,也不是结构,或者类似的东西,它更像是一个类型名
我知道这不完全一样,但也可能是为了使用它们。在这样的类型中使用weekday_enum限定符基本上是给编译器一点垃圾来解析,就像说:
enum foo { bar = 1, barre = 2, barred = 3 };
// Is sort-of the same as
typedef static const int foo;
foo bar = 1;
foo barre = 2;
foo barred = 3;
否。boost::gregorian::greg_weekday::星期三导致错误C2039:“星期三”:不是'boost::gregorian::greg_weekday'@q0987的成员抱歉,是我的错,已修复。我没有检查as_enum()返回的类型。
enum foo { bar = 1, barre = 2, barred = 3 };
// Is sort-of the same as
typedef static const int foo;
foo bar = 1;
foo barre = 2;
foo barred = 3;
typedef int foo;
struct S {
static foo var;
} p;
p.foo::var = 4; // Does this make sense? Nope...