Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is() now works for tuples #16

Open
ghost opened this issue Oct 29, 2012 · 5 comments
Open

is() now works for tuples #16

ghost opened this issue Oct 29, 2012 · 5 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2012

You might want to update Page 177 where you define the isTuple template.

import std.typecons;

template isTuple(T)
{
    static if (is(T tup == Tuple!(InnerTypes), InnerTypes...))  // now works (2.060+ methinks)
        enum isTuple = true;
    else
        enum isTuple = false;
}

void test(T)(T t)
    if (isTuple!T)
{
}

void main()
{
    auto tup = tuple(1, 2);
    test(tup);
}
@PhilippeSigaud
Copy link
Owner

You're right. A few things changed for the best in template-land since I
wrote this tutorial.

I'm a bit too much occupied by other projects right now, but for this
tutorial I plan to start a small thread on the D forum to get all template
evolutions for 2012.

On the top of my head:

  • better is
  • better CTFE
  • new _traits
  • the (a,b)=>a+b syntax seems to work correctly

Any other thing to add?

@ghost
Copy link
Author

ghost commented Nov 1, 2012

I have an upcoming fix for this as well: http://d.puremagic.com/issues/show_bug.cgi?id=1673

@PhilippeSigaud
Copy link
Owner

Man, this one is one of my top 10 D dreams.

@ghost
Copy link
Author

ghost commented Nov 2, 2012

Man, this one is one of my top 10 D dreams.

What, the is(symb == template) thing? I thought there might be workarounds by now. Anyway the pull is here:
dlang/dmd#1239

@PhilippeSigaud
Copy link
Owner

This is asked on the newsgroups at least once a month by people expecting it to work. This is a pull request that'll please many people if it passes.

Of course, it might create subtle bugs, I don't know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant