Re: compile-time detection of all pointer types in one test

2023-06-13 Thread DLearner via Digitalmars-d-learn
On Sunday, 11 June 2023 at 21:32:11 UTC, Andy wrote: [...] void main() { import std.stdio; struct foo {} foo* fooptr; static if (is(typeof(fooptr) == T*, T)) writeln("fooptr is a pointer to a ", T.stringof); else writeln(

Re: compile-time detection of all pointer types in one test

2023-06-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/11/23 5:25 PM, DLearner wrote: Is there any way of picking up, at compile-time, all pointer types in one test? What you want is `is(T : void *)` but probably to also catch all constancy flavors, `is(immutable(T) : immutable(void*))` When you use `==` in an `is` expression, it's asking

Re: compile-time detection of all pointer types in one test

2023-06-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Just to be clear where the argument goes (from templates parameters ext.): ``is(InputType : T*, T)``

Re: compile-time detection of all pointer types in one test

2023-06-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
std.traits : isPointer or ``is(int* : T*, T)``

Re: compile-time detection of all pointer types in one test

2023-06-11 Thread Andy via Digitalmars-d-learn
On Sunday, 11 June 2023 at 21:25:21 UTC, DLearner wrote: Please consider: ``` void main() { import std.stdio; struct foo { int foo1; char foo2; } foo* fooptr; void* genptr; static if (is(typeof(fooptr) == void*)) writeln("fooptr is void*");

compile-time detection of all pointer types in one test

2023-06-11 Thread DLearner via Digitalmars-d-learn
Please consider: ``` void main() { import std.stdio; struct foo { int foo1; char foo2; } foo* fooptr; void* genptr; static if (is(typeof(fooptr) == void*)) writeln("fooptr is void*"); else writeln("fooptr is not void*");