Moved filter to the public section.

It seems that Filter accidentally got put in the private section of the
file, and now that the bug making all templates public has been fixed,
Filter isn't useable.
This commit is contained in:
jmdavis 2012-09-16 21:14:08 -07:00
parent 96765530f9
commit 0ff85c49b1

View file

@ -628,6 +628,49 @@ unittest
static assert(anySatisfy!(isIntegral, int, double));
}
/++
Filters a $(D TypeTuple) using a template predicate. Returns a
$(D TypeTuple) of the elements which satisfy the predicate.
Examples:
--------------------
static assert(is(Filter!(isNarrowString, string, wstring,
dchar[], char[], dstring, int) ==
TypeTuple!(string, wstring, char[])));
static assert(is(Filter!(isUnsigned, int, byte, ubyte,
dstring, dchar, uint, ulong) ==
TypeTuple!(ubyte, uint, ulong)));
--------------------
+/
template Filter(alias pred, TList...)
{
static if(TList.length == 0)
alias TypeTuple!() Filter;
else static if(pred!(TList[0]))
alias TypeTuple!(TList[0], Filter!(pred, TList[1 .. $])) Filter;
else
alias Filter!(pred, TList[1 .. $]) Filter;
}
//Verify Examples
unittest
{
static assert(is(Filter!(isNarrowString, string, wstring,
dchar[], char[], dstring, int) ==
TypeTuple!(string, wstring, char[])));
static assert(is(Filter!(isUnsigned, int, byte, ubyte,
dstring, dchar, uint, ulong) ==
TypeTuple!(ubyte, uint, ulong)));
}
unittest
{
static assert(is(Filter!(isPointer, int, void*, char[], int*) == TypeTuple!(void*, int*)));
static assert(is(Filter!isPointer == TypeTuple!()));
}
// : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : //
private:
@ -779,48 +822,6 @@ unittest
}
/++
Filters a $(D TypeTuple) using a template predicate. Returns a
$(D TypeTuple) of the elements which satisfy the predicate.
Examples:
--------------------
static assert(is(Filter!(isNarrowString, string, wstring,
dchar[], char[], dstring, int) ==
TypeTuple!(string, wstring, char[])));
static assert(is(Filter!(isUnsigned, int, byte, ubyte,
dstring, dchar, uint, ulong) ==
TypeTuple!(ubyte, uint, ulong)));
--------------------
+/
template Filter(alias pred, TList...)
{
static if(TList.length == 0)
alias TypeTuple!() Filter;
else static if(pred!(TList[0]))
alias TypeTuple!(TList[0], Filter!(pred, TList[1 .. $])) Filter;
else
alias Filter!(pred, TList[1 .. $]) Filter;
}
//Verify Examples
unittest
{
static assert(is(Filter!(isNarrowString, string, wstring,
dchar[], char[], dstring, int) ==
TypeTuple!(string, wstring, char[])));
static assert(is(Filter!(isUnsigned, int, byte, ubyte,
dstring, dchar, uint, ulong) ==
TypeTuple!(ubyte, uint, ulong)));
}
unittest
{
static assert(is(Filter!(isPointer, int, void*, char[], int*) == TypeTuple!(void*, int*)));
static assert(is(Filter!isPointer == TypeTuple!()));
}
/*
* Instantiates the given template with the given list of parameters.
*