Re: compare types of functions.

2021-08-04 Thread ag0aep6g via Digitalmars-d-learn

On 02.08.21 22:14, vit wrote:

Why this doesn't work:
```d
template DestructorType(T){

 alias Get(T) = T;

     alias DestructorType = Get!(typeof((void*){
     T tmp;
     }));
}

struct Foo{

     ~this()@safe{}
}
```


```d
void main(){
     //Error: static assert:  `is(void function(void*) pure nothrow 
@nogc @safe : void function(void*) @safe)` is false
     static assert(is(void function(void*)pure nothrow @safe @nogc : 
DestructorType!Foo));


}

```

but this work:
```d

void main(){

     alias X = void function(void*)@safe;


     static assert(is(void function(void*)pure nothrow @safe @nogc : 
DestructorType!Foo));


}
```


Looks like you found a compiler bug. An unused alias should have any effect.


compare types of functions.

2021-08-02 Thread vit via Digitalmars-d-learn

Hello,

Why this doesn't work:
```d
template DestructorType(T){

alias Get(T) = T;

alias DestructorType = Get!(typeof((void*){
T tmp;
}));
}

struct Foo{

~this()@safe{}
}
```


```d
void main(){
//Error: static assert:  `is(void function(void*) pure 
nothrow @nogc @safe : void function(void*) @safe)` is false
static assert(is(void function(void*)pure nothrow @safe @nogc 
: DestructorType!Foo));


}

```

but this work:
```d

void main(){

alias X = void function(void*)@safe;


static assert(is(void function(void*)pure nothrow @safe @nogc 
: DestructorType!Foo));


}
```