RE:[Accessing enum values]

Dear all,
Please tell me how to get out this problem bcz I'M struct-ed past one month pls..

program:

pls don't confuse about the bellow class , it is doing just get ,set , mergege, functions only...


class bitmap {
bitmap() { clear(); }

void clear()
{
for (size_t i = 0; i < sizeof(_bitmap); ++i)
_bitmap[i] = 0;
}

void clear(EnumT pos) { _bitmap[uint(pos) / 8] &= ~(1 << (uint(pos) % 8)); }
void set(EnumT pos) { _bitmap[uint(pos) / 8] |= (1 << (uint(pos) % 8)); }
bool get(EnumT pos) const { return _bitmap[uint(pos) / 8] & (1 << (uint(pos) % 8)); }

void merge(bitmap b) {
for (size_t i = 0; i < sizeof(_bitmap); ++i)
_bitmap[i] |= b._bitmap[i];
}

void common(bitmap b) {
for (size_t i = 0; i < sizeof(_bitmap); ++i)
_bitmap[i] &= b._bitmap[i];
}

void full() {
for (size_t i = 0; i < sizeof(_bitmap); ++i)
_bitmap[i] = 0xFF;
}

bool operator==(const bitmap& bit) const {
if(sizeof(_bitmap) == sizeof(bit._bitmap)) {
for (size_t i = 0; i < sizeof(_bitmap); ++i) {
if(_bitmap[i] != bit._bitmap[i]) {
return false;
}
}
}
else {
return false;
}

return true;
}
};




enum link_value_list {
link_qos =0,
link_rssi =1 };



typedef bitmap<16, link_value_list> link_value;



struct link_states {
link_value __linkvalue;
}


int main() {
cout <<

}


question:
please don't confuse ...see I want to store or access link_qos value and store it in __linkvalue.because structure containing some more values similar types and I have to pass whole structure.

Best Wishes
Babu





Last edited on
Please use code tags when posting code; it makes things a lot easier to understand.

I can't give a specific answer to your question, but it seems to depend on what exactly a bitmap is. Did you write the class bitmap yourself, or is it in some library?
Dear look my bitmap class now.. ...It contains some functions as get(), set(), clear(), merger() ....these functions are all from boost libraries and more specifically
boost::variant.hpp

Best Regards
Babu
I am not sure I understand what exactly is your problem.

You are trying to access some enum values and you get errors? What errors are these?

Also it would be great to use [code] brackets, explain what the program was supposed to do and what and where is the problem (compiler provide information about where is the problem and what kind of problem is)
BABU Prasad G wrote:
I want to store or access link_qos value and store it in __linkvalue
Well, use the set() function:

1
2
3
link_states ls;
...
ls.__linkvalue.set(link_qos);


or get()

1
2
3
4
5
6
link_states ls;
...
if(ls.__linkvalue.get(link_qos))
{
...
}


Certainly the template is missing before class bitmap
Last edited on

Yes you are correct template is missing before the bitmap .. and thanks for your helpful fast reply , I will try out this possibility
Topic archived. No new replies allowed.