Go to the documentation of this file.00001 #ifndef REVERSEBYTES_H
00002 #define REVERSEBYTES_H
00003
00004 #include <ostream>
00005 #include <iomanip>
00006 #include <algorithm>
00010 template < typename T > T reverseBytes( T const &arg )
00011 {
00012 T nrv( arg );
00013
00014 unsigned char *p = (unsigned char *)&nrv;
00015
00016 std::reverse( p, p + sizeof( nrv ) );
00017
00018 return nrv;
00019 }
00020 #endif
00021