Getting type of range for use in member declaration

d

Solution

This would work:

typeof(chain(cast(string[])[], map!(a=>format("%s%d", "", a))(sequence!"n+1"()))) memberVar;

Another possibility would be to have a function wrap it and then take its return type and use that:

auto func(string[] nicklist)
{
    return chain(nicklist,
                 map!(a=>format("%s%d", nicklist[0], a))(sequence!"n+1"()));
}

ReturnType!func memberVar;

`ReturnType` is in std.traits.

Problem

I have a somewhat complex range I want to assign to a data member of a class. ``` chain(nicklist, map!(a=>format("%s%d", nicklist[0], a))(sequence!"n+1"())) ``` `nicklist` is just a `string[]`. Normally my trusty friend `auto` would just take care of this but for a data member I need to declare the type and I'm at a loss for what that type should be. I've tried to figure out how to use `typeof()` to get it but the runtime arguments confuse me and I haven't been able to figure out how to formulate it. (this is being used for an IRC bot. nicklist is a list of nicks I want it to try in order and after it has exhausted all of those with nick collisions it'll just try the first nick with numbers appended)

Original source