| 1 |
<html><head> |
|---|
| 2 |
<META http-equiv="content-type" content="text/html; charset=utf-8"> |
|---|
| 3 |
<title>pyd.ftype</title> |
|---|
| 4 |
</head><body> |
|---|
| 5 |
<h1>pyd.ftype</h1> |
|---|
| 6 |
<!-- Generated by Ddoc from pyd\ftype.d --> |
|---|
| 7 |
This module contains template for inferring the number of arguments, |
|---|
| 8 |
the return type, and argument types of an arbitrary function pointer. |
|---|
| 9 |
<br><br> |
|---|
| 10 |
This module was automatically generated by <u>ftype</u>.py |
|---|
| 11 |
<br><br> |
|---|
| 12 |
|
|---|
| 13 |
Written by Daniel Keep. |
|---|
| 14 |
Released to public domainâshare and enjoy (just leave my name in it, |
|---|
| 15 |
pretty please). |
|---|
| 16 |
|
|---|
| 17 |
<br><br> |
|---|
| 18 |
|
|---|
| 19 |
<dl><dt><big>template NumberOfArgs(Tf)</big></dt> |
|---|
| 20 |
<dd>This template will attempt to determine the number of arguments the |
|---|
| 21 |
supplied function pointer or delegate type takes. It supports a maximum of |
|---|
| 22 |
10 arguments. |
|---|
| 23 |
<br><br> |
|---|
| 24 |
<b>Example:</b><br> |
|---|
| 25 |
<pre class="d_code"> <font color=blue>void</font> fnWithThreeArgs(<font color=blue>byte</font> a, <font color=blue>short</font> b, <font color=blue>int</font> c) {} |
|---|
| 26 |
<font color=blue>const</font> <font color=blue>uint</font> numArgs = <u>NumberOfArgs</u>!(<font color=blue>typeof</font>(&fnWithThreeArgs)); |
|---|
| 27 |
</pre> |
|---|
| 28 |
|
|---|
| 29 |
<br><br> |
|---|
| 30 |
|
|---|
| 31 |
<dl></dl> |
|---|
| 32 |
</dd> |
|---|
| 33 |
<dt><big>template ReturnType(Tf)</big></dt> |
|---|
| 34 |
<dd>This template will attempt to discern the return type of the supplied |
|---|
| 35 |
function pointer or delegate type. It supports callables with a maximum of |
|---|
| 36 |
10 arguments. |
|---|
| 37 |
<br><br> |
|---|
| 38 |
<b>Example:</b><br> |
|---|
| 39 |
<pre class="d_code"> <font color=blue>uint</font> returnsANumber() { <font color=blue>return</font> 42; } |
|---|
| 40 |
<font color=blue>alias</font> <u>ReturnType</u>!(<font color=blue>typeof</font>(&returnsANumber)) RType; <font color=green>// RType == uint |
|---|
| 41 |
</font></pre> |
|---|
| 42 |
|
|---|
| 43 |
<br><br> |
|---|
| 44 |
|
|---|
| 45 |
<dl></dl> |
|---|
| 46 |
</dd> |
|---|
| 47 |
<dt><big>template ArgType(Tf,uint n)</big></dt> |
|---|
| 48 |
<dd>This template will attempt to extract the type of the nth argument of the |
|---|
| 49 |
given function pointer or delegate type. It supports callables with up to |
|---|
| 50 |
10 arguments. |
|---|
| 51 |
<br><br> |
|---|
| 52 |
<b>Example:</b><br> |
|---|
| 53 |
<pre class="d_code"> <font color=blue>void</font> intShortBool(<font color=blue>int</font> a, <font color=blue>short</font> b, <font color=blue>bool</font> c) {} |
|---|
| 54 |
<font color=blue>alias</font> <u>ArgType</u>!(<font color=blue>typeof</font>(&intShortBool), 2) TArg2; <font color=green>// TArg2 == short |
|---|
| 55 |
</font></pre> |
|---|
| 56 |
|
|---|
| 57 |
<br><br> |
|---|
| 58 |
|
|---|
| 59 |
<dl></dl> |
|---|
| 60 |
</dd> |
|---|
| 61 |
<dt><big>template MIN_ARGS(alias fn)</big></dt> |
|---|
| 62 |
<dd>This template will attempt to determine the minimum number of arguments a |
|---|
| 63 |
function can accept. Note that this accepts an alias parameter rather than a |
|---|
| 64 |
function pointer type, as the function and delegate types contain no |
|---|
| 65 |
information about default arguments. |
|---|
| 66 |
<br><br> |
|---|
| 67 |
(Written by Kirk McDonald.) |
|---|
| 68 |
|
|---|
| 69 |
<br><br> |
|---|
| 70 |
|
|---|
| 71 |
<dl></dl> |
|---|
| 72 |
</dd> |
|---|
| 73 |
</dl> |
|---|
| 74 |
|
|---|
| 75 |
<hr><small>Page generated by <a href="http://www.digitalmars.com/d/ddoc.html">Ddoc</a>. </small> |
|---|
| 76 |
</body></html> |
|---|