Function signature constraint syntax

Philippe Sigaud philippe.sigaud at gmail.com
Thu Feb 2 21:51:56 PST 2012


>
> Quick question: I have a function that takes an alias parameter:
>
>        struct X { ... };
>
>        void func(alias G)(object O) {
>                ...
>                X x = ...;
>                G(x);
>                ...
>        }
>
> How do I write a signature constraint that essentially specifies that G
> should take a parameter of type X and return void?

if ( is(typeof(G(X.init ) ) == void))

For the expression to work, G must accept an X and return a void.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120203/e55992ce/attachment.html>


More information about the Digitalmars-d-learn mailing list