ss_int24_t and ss_uint24_t are integers
[lsnes.git] / include / library / int24.hpp
blobf802cbf829b110ad53071ddcf44e75e63294cc81
1 #ifndef _library__int24__hpp__incuded__
2 #define _library__int24__hpp__incuded__
4 #include <cstdint>
6 class ss_uint24_t
8 public:
9 ss_uint24_t() throw();
10 ss_uint24_t(uint32_t v) throw();
11 operator uint32_t() const throw();
12 bool operator<(const ss_uint24_t& v) const throw() { return (uint32_t)*this < (uint32_t)v; }
13 bool operator<=(const ss_uint24_t& v) const throw() { return (uint32_t)*this <= (uint32_t)v; }
14 bool operator==(const ss_uint24_t& v) const throw() { return (uint32_t)*this == (uint32_t)v; }
15 bool operator!=(const ss_uint24_t& v) const throw() { return (uint32_t)*this != (uint32_t)v; }
16 bool operator>=(const ss_uint24_t& v) const throw() { return (uint32_t)*this >= (uint32_t)v; }
17 bool operator>(const ss_uint24_t& v) const throw() { return (uint32_t)*this > (uint32_t)v; }
18 bool operator==(uint32_t v) const throw() { return (uint32_t)*this == (uint32_t)v; }
19 bool operator!=(uint32_t v) const throw() { return (uint32_t)*this != (uint32_t)v; }
20 private:
21 char v[3];
24 class ss_int24_t
26 public:
27 ss_int24_t() throw();
28 ss_int24_t(int32_t v) throw();
29 ss_int24_t(const ss_uint24_t& v) throw();
30 operator int32_t() const throw();
31 bool operator<(const ss_int24_t& v) const throw() { return (int32_t)*this < (int32_t)v; }
32 bool operator<=(const ss_int24_t& v) const throw() { return (int32_t)*this <= (int32_t)v; }
33 bool operator==(const ss_int24_t& v) const throw() { return (int32_t)*this == (int32_t)v; }
34 bool operator!=(const ss_int24_t& v) const throw() { return (int32_t)*this != (int32_t)v; }
35 bool operator>=(const ss_int24_t& v) const throw() { return (int32_t)*this >= (int32_t)v; }
36 bool operator>(const ss_int24_t& v) const throw() { return (int32_t)*this > (int32_t)v; }
37 bool operator==(int32_t v) const throw() { return (uint32_t)*this == (uint32_t)v; }
38 bool operator!=(int32_t v) const throw() { return (uint32_t)*this != (uint32_t)v; }
39 private:
40 char v[3];
43 template<typename T> struct is_ss_int24 { const static bool flag = false; };
44 template<> struct is_ss_int24<ss_uint24_t> { const static bool flag = true; };
45 template<> struct is_ss_int24<ss_int24_t> { const static bool flag = true; };
48 #endif