Sha256: c1ced72332955693c14243b47e7cab19aeccf8206512188841c11f2c25064928
Contents?: true
Size: 862 Bytes
Versions: 1
Compression:
Stored size: 862 Bytes
Contents
// -*- c++ -*- #pragma once #ifndef __XOT_UTIL_H__ #define __XOT_UTIL_H__ #include <stdint.h> namespace Xot { int bit2byte (int bits); int byte2bit (int bytes); template <typename T> inline T clip (T minval, T maxval, T value) { return value > maxval ? maxval : (value < minval ? minval : value); } template <typename T> inline T* set_pointer_flag (T* pointer, bool flag = true) { uintptr_t intval = *(uintptr_t*) &pointer; if (flag) intval |= 0x1; else intval &= ~0x1; return *(T**) &intval; } template <typename T> inline const T* set_pointer_flag (const T* pointer, bool flag = true) { return set_pointer_flag(const_cast<T*>(pointer), flag); } template <typename T> inline bool get_pointer_flag (const T* pointer) { uintptr_t intval = *(uintptr_t*) &pointer; return intval & 0x1; } }// Xot #endif//EOH
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xot-0.1.7 | include/xot/util.h |