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

Add a Wrapped template to std.traits #42

Closed
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@mrmonday
Contributor

mrmonday commented May 9, 2011

Wrap types with the given template:
eg. Wrapped!(A, B, C) == TypeTuple!(A!B, A!C).

Added Wrapped!(T, U...) to wrap types U... using template T.
eg. Wrapped!(A, B, C) == TypeTuple!(A!B, A!C).
@mrmonday

This comment has been minimized.

Contributor

mrmonday commented May 10, 2011

I'm thinking about renaming this to WrapTypes!(B, C).with(A) - would this be a better name?

@mrmonday

This comment has been minimized.

Contributor

mrmonday commented May 11, 2011

Done. Sorry about the merge, I forgot to rebase.

@jmdavis

This comment has been minimized.

Member

jmdavis commented May 15, 2011

I'm afraid that I don't quite get what the point of this template is. What exactly are you trying to do with it?

@mrmonday

This comment has been minimized.

Contributor

mrmonday commented May 15, 2011

It allows for things like the following:

struct Foo(T...)
{
    WrapTypes!(T).With!Unqual values;
}
void foo(const int a, immutable string b);
Foo!(ParameterTupleOf!foo) myFoo;

Or more interesting, I'm using it to "emulate" multiple inheritance (of course, I still need to call suport methods manually, that's just a simple loop though, as seen here):

class Foo(T...)
{
    WrapTypes!(T).With!(.Foo) mParents;
    this()
    {
        foreach (parent; mParents)
        {
            parent = new typeof(parent);
        }
    }
}

@mrmonday mrmonday closed this May 15, 2011

@mrmonday mrmonday reopened this May 15, 2011

@pszturmaj

This comment has been minimized.

pszturmaj commented May 15, 2011

Seems like std.typetuple.staticMap.

@mrmonday

This comment has been minimized.

Contributor

mrmonday commented May 15, 2011

So it does. Never mind then.

@mrmonday mrmonday closed this May 15, 2011

NilsBossung pushed a commit to NilsBossung/phobos that referenced this pull request Jun 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment