digitalmars.D.learn - static if "Pointer-Type"
- Philipp Heise (24/24) Mar 05 2006 Hi,
- Thomas Kuehne (24/47) Mar 05 2006 -----BEGIN PGP SIGNED MESSAGE-----
Hi,
i have the following problem in a template:
class SomeClass(T) {
T[] elements;
...
/*code for adding and removing elements*/
...
public int contains(T x) {
/*x could be null if T is a pointer-type*/
static if("T is a Pointer-Type") { /*<- How can i do this ???*/
if(x is null){
foreach(T y;elements){
if(y is null) return true;
}
return false;
}
}
...
/*rest of the method*/
...
}
...
}
thnx Philipp
Mar 05 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Philipp Heise schrieb am 2006-03-05:
Hi,
i have the following problem in a template:
class SomeClass(T) {
T[] elements;
...
/*code for adding and removing elements*/
...
public int contains(T x) {
/*x could be null if T is a pointer-type*/
static if("T is a Pointer-Type") { /*<- How can i do this ???*/
if(x is null){
foreach(T y;elements){
if(y is null) return true;
}
return false;
}
}
...
/*rest of the method*/
...
}
...
}
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFECxlp3w+/yD4P9tIRAmhUAKCj6VIj6TRqQ6k+JAm7nG+k9H35PACgnRKs
d9hij5BBjqOSB+3hpexDtRg=
=XyVC
-----END PGP SIGNATURE-----
Mar 05 2006








Thomas Kuehne <thomas-dloop kuehne.cn>