<div dir="ltr"><div dir="ltr">On Thu, Jul 30, 2020 at 3:45 PM Petar via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thursday, 30 July 2020 at 04:56:55 UTC, Petar Kirov <br>
[ZombineDev] wrote:<br>
> On Wednesday, 29 July 2020 at 16:31:08 UTC, Jean-Louis Leroy <br>
> wrote:<br>
>> [...]<br>
><br>
> My point, that you can't do much useful processing with <br>
> `__parameters` (except pass all of subset of it), still stands.<br>
><br>
> Say you have a function with N parameters. Some of those <br>
> parameters are integers and may have a UDA attached to them <br>
> that specifies the minimum and maximum value they may receive. <br>
> For example:<br>
><br>
> R fun(<br>
>   scope P1 arg1,<br>
>   return int* arg2,<br>
>   lazy @intetval(-16, 320) long arg3,<br>
>   @interval(0, 127) uint arg4,<br>
>   ref @interval(0, 8192) size_t arg5<br>
> );<br>
><br>
> The task is create a template, which given a function type like <br>
> typeof(&fun) returns a new function type with all integer <br>
> parameters replaced by the smallest type that is big enough to <br>
> hold the interval specified by the UDA and preserves all <br>
> storage classes.<br>
><br>
><br>
> R hun(<br>
>   scope P1 arg1,<br>
>   return int* arg2,<br>
>   lazy @intetval(-16, 320) short arg3,<br>
>   @interval(0, 127) ubyte arg4,<br>
>   ref @interval(0, 8192) ushort arg5<br>
> );<br>
><br>
> The way I'd like to go about solving this is like this:<br>
><br>
> template TightenIntegerParams(Fun)<br>
> {<br>
>   alias TightenIntegerParams =<br>
>     ReturnType!Fun function(<br>
>       staticMap!(<br>
>         TightenParam,<br>
>         Parameters!Fun<br>
>       )<br>
>     );<br>
> }<br>
><br>
> However the moment staticMap internally does `Args[i]` in order <br>
> to pass the i-th element to the mapping function `F` we lose <br>
> all information about the storage classes and UDAs.<br>
<br>
I now saw that Manu clarified what he meant.<br>
<br>
Also I do realize that what we actually need is for <br>
`Parameters!fun[0]` to return a parameter object that includes <br>
not just the type but also the parameter name, UDAs attached and <br>
storage classes. If for example `ref` was a type qualifier, or <br>
just otherwise preserved by `alias`-ing it would help, but not <br>
solve the whole issue.<br></blockquote><div><br></div><div>UDA's and default args are in-language concepts, alias/tuples can handle them, and don't require any particularly special meta to handle.<br></div></div></div>