How can I check if a type is a pointer?
rempas
rempas at tutanota.com
Sat Jun 25 14:18:10 UTC 2022
For example, something like the following:
```d
void main() {
char accepted_type;
char* non_accepted_type;
if (__traits(isPointer, typeof(accepted_type))) {
// The type is not accepted
}
else { /* The type is not a pointer so its accepted */ }
if (__traits(isPointer, typeof(non_accepted_type))) {
// The type is not accepted
}
else { /* The type is not a pointer so its accepted */ }
}
```
In that example, the first comparison will execute the second
branch and for the second comparison,
it will execute the first branch. Of course, this trait doesn't
exist I used an example to show what I want
to do. Any ideas?
More information about the Digitalmars-d-learn
mailing list