Let's see the following code:

```d
void test_fn(T)(T val) {
pragma(msg, "The type of the pointer is: " ~ typeof(*val).stringof);
}

extern (C) void main() {
  int* int_ptr = cast(int*)0x1037;
  char* char_ptr = cast(char*)0x1037;

  test_fn(int_ptr);
  test_fn(char_ptr);
}
```

This function takes a templates argument that can be any (pointer) type and shows the scalar type of the pointer (at compile time). I'm using the "typeof" operator and I'm referencing the pointer so I can get the scalar type. This will work great for single pointer values but what about pointers to pointers like: `int****`? Is there a way that I would be able to always get the scalar type of a pointer regardless of how many levels it is? As always, I'm searching for a solution that will work in `BetterC`.

Reply via email to