Skip to content

Commit

Permalink
optimize and reduce imports for aliasSeqOf
Browse files Browse the repository at this point in the history
  • Loading branch information
9il committed Apr 26, 2016
1 parent df99fc8 commit bbdf3be
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions std/meta.d
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,6 @@ unittest
*/
template aliasSeqOf(alias range)
{
import std.range : isInputRange;
import std.traits : isArray, isNarrowString;

alias ArrT = typeof(range);
Expand All @@ -995,15 +994,18 @@ template aliasSeqOf(alias range)
alias aliasSeqOf = AliasSeq!(aliasSeqOf!(range[0 .. $/2]), aliasSeqOf!(range[$/2 .. $]));
}
}
else static if (isInputRange!ArrT)
{
import std.array : array;
alias aliasSeqOf = aliasSeqOf!(array(range));
}
else
{
import std.string : format;
static assert(false, format("Cannot transform %s of type %s into a AliasSeq.", range, ArrT.stringof));
import std.range.primitives : isInputRange;
static if (isInputRange!ArrT)
{
import std.array : array;
alias aliasSeqOf = aliasSeqOf!(array(range));
}
else
{
static assert(false, "Cannot transform range of type " ~ ArrT.stringof ~ " into a AliasSeq.");
}
}
}

Expand Down

0 comments on commit bbdf3be

Please sign in to comment.