boost - byte order
-
hallo leute,
kleine frage bzgl boost::dynamic_bitset:#include <iostream> #include <iomanip> #include <boost/dynamic_bitset.hpp> template < typename T > inline T highbit(T& t) { return t = (((T)(-1)) >> 1) + 1; } template < typename T > std::ostream& bin(T& value, std::ostream &o) { for ( T bit = highbit(bit); bit; bit >>= 1 ) { o << ( ( value & bit ) ? '1' : '0' ); } return o; } int main(int, char*[]) { unsigned int value = 0x701; boost::dynamic_bitset<unsigned char> x(16, value); // all 0's by default unsigned char y[2]; memset(&y, 0, sizeof(y)); std::cout << "x[i]: "; for (boost::dynamic_bitset<>::size_type i = 0; i < x.size(); ++i) std::cout << x[i]; std::cout << "\n"; std::cout << "x: " << x << "\n"; std::cout << "x.num_blocks(): " << x.num_blocks() << std::endl; to_block_range(x, y); for(unsigned int i = 0; i < 2; i++) { bin(y[i], std::cout); std::cout << std::endl; } std::cout << "\n"; return EXIT_SUCCESS; }wenn ich das char array anschaue steht dann da (binaer):
y[0] = 00000001
y[1] = 00000111ich möchte da gerne die byte ordner schon im boost::dynamic_bitset aendern, wie kann ich auf den block zugreifen?
soll dann im char array folgend aussehen:
y[0] = 00000111
y[1] = 00000001
[/cpp]bye