P
Peter Hemmingsen
Hi,
I'm trying to write a function taking an "flagged" enum as parameter. The
function should then loop through the enum and do some stuff for each flag
that are set. Below is some sample code showing what I'm trying to do. The
problem is in the line:
if (val->GetValue(i) & it)
as there is no binary and operator on the object returned by GetValue. I've
tried to cast the GetValue return type to a InfoTypes type but that fails as
well.
Any suggestion would be highly appreciated,- thanks.
Peter
SAMPLE CODE:
[Flags] public __value enum InfoTypes
{p=0x80000000,s=0x40000000,t=0x20000000};
InfoTypes it =p & s;
DoStuff (it);
....
void DoStuff (InfoTypes it) {
Type* ty=__typeof(InfoTypes);
Array *val=Enum::GetValues(ty);
for (i=0;i<val->Length();i++) {
if (val->GetValue(i) & it)
DoSomeThing();
}
}
I'm trying to write a function taking an "flagged" enum as parameter. The
function should then loop through the enum and do some stuff for each flag
that are set. Below is some sample code showing what I'm trying to do. The
problem is in the line:
if (val->GetValue(i) & it)
as there is no binary and operator on the object returned by GetValue. I've
tried to cast the GetValue return type to a InfoTypes type but that fails as
well.
Any suggestion would be highly appreciated,- thanks.
Peter
SAMPLE CODE:
[Flags] public __value enum InfoTypes
{p=0x80000000,s=0x40000000,t=0x20000000};
InfoTypes it =p & s;
DoStuff (it);
....
void DoStuff (InfoTypes it) {
Type* ty=__typeof(InfoTypes);
Array *val=Enum::GetValues(ty);
for (i=0;i<val->Length();i++) {
if (val->GetValue(i) & it)
DoSomeThing();
}
}