Skip to content

Commit

Permalink
Merge pull request #4155 from 9il/imports
Browse files Browse the repository at this point in the history
optimize and reduce imports for `aliasSeqOf`
  • Loading branch information
DmitryOlshansky committed Apr 26, 2016
2 parents 23fcb24 + bbdf3be commit 61dfd48
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 @@ -1004,7 +1004,6 @@ unittest
*/
template aliasSeqOf(alias range)
{
import std.range : isInputRange;
import std.traits : isArray, isNarrowString;

alias ArrT = typeof(range);
Expand All @@ -1023,15 +1022,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 61dfd48

Please sign in to comment.