mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
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:
parent
96765530f9
commit
0ff85c49b1
1 changed files with 43 additions and 42 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue