Re: How can I get the scalar type of a pointer to pointer (and in even deeper levels)

2023-03-11 Thread rempas via Digitalmars-d-learn
On Saturday, 11 March 2023 at 13:37:26 UTC, ag0aep6g wrote: On 11.03.23 14:22, rempas wrote: On Saturday, 11 March 2023 at 12:59:59 UTC, ag0aep6g wrote: alias Foo(T : U*, U) = Foo!U; alias Foo(T) = T; static assert(is(Foo!(int*) == int)); static assert(is(Foo!(int**) == int)); static

Re: How can I get the scalar type of a pointer to pointer (and in even deeper levels)

2023-03-11 Thread ag0aep6g via Digitalmars-d-learn
On 11.03.23 14:22, rempas wrote: On Saturday, 11 March 2023 at 12:59:59 UTC, ag0aep6g wrote: alias Foo(T : U*, U) = Foo!U; alias Foo(T) = T; static assert(is(Foo!(int*) == int)); static assert(is(Foo!(int**) == int)); static assert(is(Foo!(int***) == int)); static assert(is(Foo!(int) ==

Re: How can I get the scalar type of a pointer to pointer (and in even deeper levels)

2023-03-11 Thread rempas via Digitalmars-d-learn
On Saturday, 11 March 2023 at 12:59:59 UTC, ag0aep6g wrote: alias Foo(T : U*, U) = Foo!U; alias Foo(T) = T; static assert(is(Foo!(int*) == int)); static assert(is(Foo!(int**) == int)); static assert(is(Foo!(int***) == int)); static assert(is(Foo!(int) == int)); Wait, but "Foo" is defined

Re: How can I get the scalar type of a pointer to pointer (and in even deeper levels)

2023-03-11 Thread ag0aep6g via Digitalmars-d-learn
On 11.03.23 13:49, rempas wrote: 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`. alias Foo(T : U*, U)

How can I get the scalar type of a pointer to pointer (and in even deeper levels)

2023-03-11 Thread rempas via Digitalmars-d-learn
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