1#ifndef _STDEX_TYPE_ZERO_H
2#define _STDEX_TYPE_ZERO_H
20 type_zero() { memset(&
static_cast<T&
>(*
this), 0,
sizeof(T)); }
23 template<
class T, std::
size_t N>
24 struct type_zero<T[N]>
30 type_zero() { memset(data, 0,
sizeof(data)); }
32 T& operator[](
int n) {
return data[n]; }
33 const T& operator[](
int n)
const {
return data[n]; }
35 T& operator*() {
return *data; }
36 const T& operator*()
const {
return *data; }
38 friend T* operator+(type_zero &arr,
int n) {
return arr.data + n; }
39 friend T* operator+(
int n, type_zero &arr) {
return n + arr.data; }
40 friend const T* operator+(
const type_zero &arr,
int n) {
return arr.data + n; }
41 friend const T* operator+(
int n,
const type_zero &arr) {
return n + arr.data; }
43 friend T* operator-(type_zero &arr,
int n) {
return arr.data - n; }
44 friend T* operator-(
int n, type_zero &arr) {
return n - arr.data; }
45 friend const T* operator-(
const type_zero &arr,
int n) {
return arr.data - n; }
46 friend const T* operator-(
int n,
const type_zero &arr) {
return n - arr.data; }
48 friend bool operator>(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data > rhs.data; }
49 friend bool operator>(
const T *lhs,
const type_zero &rhs) {
return lhs > rhs.data; }
50 friend bool operator>(
const type_zero &lhs,
const T *rhs) {
return lhs.data > rhs; }
52 friend bool operator>=(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data >= rhs.data; }
53 friend bool operator>=(
const T *lhs,
const type_zero &rhs) {
return lhs >= rhs.data; }
54 friend bool operator>=(
const type_zero &lhs,
const T *rhs) {
return lhs.data >= rhs; }
56 friend bool operator<(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data < rhs.data; }
57 friend bool operator<(
const T *lhs,
const type_zero &rhs) {
return lhs < rhs.data; }
58 friend bool operator<(
const type_zero &lhs,
const T *rhs) {
return lhs.data < rhs; }
60 friend bool operator<=(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data <= rhs.data; }
61 friend bool operator<=(
const T *lhs,
const type_zero &rhs) {
return lhs <= rhs.data; }
62 friend bool operator<=(
const type_zero &lhs,
const T *rhs) {
return lhs.data <= rhs; }
64 friend bool operator==(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data == rhs.data; }
66 operator array_t&() {
return data; }
67 operator const array_t&()
const {
return data; }
70 template<
class T, std::
size_t N>
71 struct type_zero<const T[N]>
77 type_zero() { memset(data, 0,
sizeof(data)); }
79 T& operator[](
int n) {
return data[n]; }
80 const T& operator[](
int n)
const {
return data[n]; }
82 T& operator*() {
return *data; }
83 const T& operator*()
const {
return *data; }
85 friend T* operator+(type_zero &arr,
int n) {
return arr.data + n; }
86 friend T* operator+(
int n, type_zero &arr) {
return n + arr.data; }
87 friend const T* operator+(
const type_zero &arr,
int n) {
return arr.data + n; }
88 friend const T* operator+(
int n,
const type_zero &arr) {
return n + arr.data; }
90 friend T* operator-(type_zero &arr,
int n) {
return arr.data - n; }
91 friend T* operator-(
int n, type_zero &arr) {
return n - arr.data; }
92 friend const T* operator-(
const type_zero &arr,
int n) {
return arr.data - n; }
93 friend const T* operator-(
int n,
const type_zero &arr) {
return n - arr.data; }
95 friend bool operator>(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data > rhs.data; }
96 friend bool operator>(
const T *lhs,
const type_zero &rhs) {
return lhs > rhs.data; }
97 friend bool operator>(
const type_zero &lhs,
const T *rhs) {
return lhs.data > rhs; }
99 friend bool operator>=(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data >= rhs.data; }
100 friend bool operator>=(
const T *lhs,
const type_zero &rhs) {
return lhs >= rhs.data; }
101 friend bool operator>=(
const type_zero &lhs,
const T *rhs) {
return lhs.data >= rhs; }
103 friend bool operator<(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data < rhs.data; }
104 friend bool operator<(
const T *lhs,
const type_zero &rhs) {
return lhs < rhs.data; }
105 friend bool operator<(
const type_zero &lhs,
const T *rhs) {
return lhs.data < rhs; }
107 friend bool operator<=(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data <= rhs.data; }
108 friend bool operator<=(
const T *lhs,
const type_zero &rhs) {
return lhs <= rhs.data; }
109 friend bool operator<=(
const type_zero &lhs,
const T *rhs) {
return lhs.data <= rhs; }
111 friend bool operator==(
const type_zero &lhs,
const type_zero &rhs) {
return lhs.data == rhs.data; }
113 operator array_t&() {
return data; }
114 operator const array_t&()
const {
return data; }