Comparing Two Type Tuples

Philippe Sigaud philippe.sigaud at gmail.com
Mon Apr 5 04:51:12 PDT 2010


On Mon, Apr 5, 2010 at 12:52, Philippe Sigaud <philippe.sigaud at gmail.com>wrote:


> That's useful to compare two functions:
>
> template sameArgs(alias fun1, alias fun2) {
>     static if (compare!(ParameterTypeTuple!fun1, ParameterTypeTuple!fun2))
>

Ugh, forget this example, in this case we know the original tuples, so == is
simpler and cleaner.

Another interesting thing to test is if one typetuple can be converted into
another.
Maybe like this:

bool compatibleTypeTuples(TT...) {
    TT[0..$/2] tt1;
    TT[$/2..$] tt2;
    static if (__traits(compiles, tt1 = tt2))
        return true;
    else
        return false;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100405/57abac91/attachment.html>


More information about the Digitalmars-d-learn mailing list