www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Function Pointer

reply Vino <akashvino79 gmail.com> writes:
Hi All,

  Request your help on hot to create a pointer for a function 
whose function type is Result.

```
ReturnType!(typeof(&test)).stringof; // Result

From
Vino
```
Aug 30 2023
parent reply Paul Backus <snarwin gmail.com> writes:
On Wednesday, 30 August 2023 at 17:48:19 UTC, Vino wrote:
 Hi All,

  Request your help on hot to create a pointer for a function 
 whose function type is Result.

 ```
 ReturnType!(typeof(&test)).stringof; // Result

 From
 Vino
 ```
To get a function pointer type from a function type, you can add `*` on the end: void func(int) {} alias FuncType = typeof(func); pragma(msg, FuncType); // void(int) alias FuncPtrType = FuncType*; pragma(msg, FuncPtrType); // void function(int) static assert(is(FuncPtrType == typeof(&func)));
Aug 30 2023
parent vino <akashvino79 gmail.com> writes:
On Wednesday, 30 August 2023 at 21:12:57 UTC, Paul Backus wrote:
 On Wednesday, 30 August 2023 at 17:48:19 UTC, Vino wrote:
 Hi All,

  Request your help on hot to create a pointer for a function 
 whose function type is Result.

 ```
 ReturnType!(typeof(&test)).stringof; // Result

 From
 Vino
 ```
To get a function pointer type from a function type, you can add `*` on the end: void func(int) {} alias FuncType = typeof(func); pragma(msg, FuncType); // void(int) alias FuncPtrType = FuncType*; pragma(msg, FuncPtrType); // void function(int) static assert(is(FuncPtrType == typeof(&func)));
Thank you very much
Aug 31 2023