c++ - Save a Bitset into a Struct Field -


i decedied not use macros bitwise operations rather use bitset. intending is, receive struct evaluate bits appened them struct.

i receive struct, say:

typedef struct{ uint8 status; //!< status } msgstatus; 

i need status , check each received bit, create bitset of recevied struct:

m_msgbits = new msgstatus(); bitset<8> msgbits(m_msgbits->status); // evaluate bits  

now, after evaluation need appened received bits struct, say:

typedef struct{ uint32 status; //!< status } msgoverallstatus; 

so, is:

m_overallstatus = new msgoverallstatus(); bitset<16> overallbits(m_overallstatus->status); m_overallstatus.reset(); // 00000000 00000000  //then append bits in msgbits in overallbits, example: overallbits.set(0, msgbits[0]); overallbits.set(1, msgbits[1]); overallbits.set(2, msgbits[2]);  //==== here dunno how ==== m_overallstatus->status = overallbits; 

i want assign bits struct field, error: cannot convert ‘std::bitset<16u>’ ‘uint16’ in assignment

i dont want change struct field type, can do? apologize how silly question.

thanks in advance

use std::bitset's member function to_ulong, returns bits in set unsigned long.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -