Improve the auto-swapping struct a bit.

Specifically:
 * Don't override &&/|| - that kills short circuiting.
 * Consistently return a swapped type from operators.
 * Add a few more missing operators.
This commit is contained in:
Unknown W. Brackets committed 2013-07-28 21:03:44 -07:00
1 parent f5dc650fd3
commit 524064a02e
2 files changed
+303 -245

No files matched your search

+2
View File
@@ -175,10 +175,12 @@ private:
#ifdef _MSC_VER
inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
inline unsigned int bswap16(unsigned int x) { return _byteswap_ushort(x); }
#else
// TODO: speedup
inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)swap32(x) << 32) | swap32(x >> 32); }
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
#endif