C:/Projekte/C++/FlowVIS_107/src/reverseBytes.h

Go to the documentation of this file.
00001 #ifndef REVERSEBYTES_H
00002 #define REVERSEBYTES_H
00003 
00004 #include "common.h"
00005 
00006 #include <ostream>
00007 #include <iomanip>
00008 #include <algorithm>
00009 
00010 
00011 
00012 template < typename T > T reverseBytes( T const &arg )
00013 {
00014         T nrv( arg );           
00015         // reinterpret_cast ..
00016         unsigned char *p = (unsigned char *)&nrv;
00017         // don't you just love namespaces ...
00018         std::reverse( p, p + sizeof( nrv ) );
00019         // Now for the UB ...
00020         return nrv;
00021 }
00022 #endif
00023 

Generated on Mon Jan 21 14:50:12 2008 for VisLU by  doxygen 1.5.4