Mercurial > projects > orange
comparison orange/util/Traits.d @ 26:78e5fef4bbf2 experimental
Third step in refactoring the API. Stating to add unit tests.
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Tue, 19 Oct 2010 10:22:10 +0200 |
parents | c4e7e64ffb67 |
children | fc315d786f24 |
comparison
equal
deleted
inserted
replaced
25:b51e953f79eb | 26:78e5fef4bbf2 |
---|---|
121 template isReference (T) | 121 template isReference (T) |
122 { | 122 { |
123 const bool isReference = isObject!(T) || isPointer!(T); | 123 const bool isReference = isObject!(T) || isPointer!(T); |
124 } | 124 } |
125 | 125 |
126 template isTypeDef (T) | 126 template isTypedef (T) |
127 { | 127 { |
128 const bool isTypeDef = is(T == typedef); | 128 const bool isTypedef = is(T == typedef); |
129 } | 129 } |
130 | 130 |
131 template isVoid (T) | 131 template isVoid (T) |
132 { | 132 { |
133 const bool isVoid = is(T == void); | 133 const bool isVoid = is(T == void); |
134 } | 134 } |
135 | 135 |
136 template BaseTypeOfArray (T) | 136 template ElementTypeOfArray(T : T[]) |
137 { | 137 { |
138 static if (is(T U : U[])) | 138 alias T ElementTypeOfArray; |
139 alias BaseTypeOfArray!(U) BaseTypeOfArray; | |
140 | |
141 else | |
142 alias T BaseTypeOfArray; | |
143 } | 139 } |
144 | 140 |
145 template BaseTypeOfPointer (T) | 141 template BaseTypeOfPointer (T) |
146 { | 142 { |
147 static if (is(T U : U*)) | 143 static if (is(T U : U*)) |
149 | 145 |
150 else | 146 else |
151 alias T BaseTypeOfPointer; | 147 alias T BaseTypeOfPointer; |
152 } | 148 } |
153 | 149 |
154 template BaseTypeOfTypeDef (T) | 150 template BaseTypeOfTypedef (T) |
155 { | 151 { |
156 static if (is(T U == typedef)) | 152 static if (is(T U == typedef)) |
157 alias BaseTypeOfTypeDef!(U) BaseTypeOfTypeDef; | 153 alias BaseTypeOfTypedef!(U) BaseTypeOfTypedef; |
158 | 154 |
159 else | 155 else |
160 alias T BaseTypeOfTypeDef; | 156 alias T BaseTypeOfTypedef; |
157 } | |
158 | |
159 template BaseTypeOfEnum (T) | |
160 { | |
161 static if (is(T U == enum)) | |
162 alias BaseTypeOfEnum!(U) BaseTypeOfEnum; | |
163 | |
164 else | |
165 alias T BaseTypeOfEnum; | |
161 } | 166 } |
162 | 167 |
163 template KeyTypeOfAssociativeArray (T) | 168 template KeyTypeOfAssociativeArray (T) |
164 { | 169 { |
165 static assert(isAssociativeArray!(T), "The type needs to be an associative array"); | 170 static assert(isAssociativeArray!(T), "The type needs to be an associative array"); |