mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
TypeTuple -> MetaList inside Phobos
This commit is contained in:
parent
73f773838d
commit
82f54a38d3
42 changed files with 615 additions and 613 deletions
|
@ -132,7 +132,7 @@ efficient search, but one that only supports matching on equality:
|
|||
|
||||
@safe unittest
|
||||
{
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
if (auto pos = 3.among(1, 2, 3))
|
||||
assert(pos == 3);
|
||||
|
@ -144,7 +144,7 @@ efficient search, but one that only supports matching on equality:
|
|||
assert(position);
|
||||
assert(position == 1);
|
||||
|
||||
alias values = TypeTuple!("foo", "bar", "baz");
|
||||
alias values = MetaList!("foo", "bar", "baz");
|
||||
auto arr = [values];
|
||||
assert(arr[0 .. "foo".among(values)] == ["foo"]);
|
||||
assert(arr[0 .. "bar".among(values)] == ["foo", "bar"]);
|
||||
|
|
|
@ -294,15 +294,15 @@ private struct _Cache(R, bool bidir)
|
|||
private
|
||||
{
|
||||
import std.algorithm.internal : algoFormat;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
alias E = ElementType!R;
|
||||
alias UE = Unqual!E;
|
||||
|
||||
R source;
|
||||
|
||||
static if (bidir) alias CacheTypes = TypeTuple!(UE, UE);
|
||||
else alias CacheTypes = TypeTuple!UE;
|
||||
static if (bidir) alias CacheTypes = MetaList!(UE, UE);
|
||||
else alias CacheTypes = MetaList!UE;
|
||||
CacheTypes caches;
|
||||
|
||||
static assert(isAssignable!(UE, E) && is(UE : E),
|
||||
|
@ -817,8 +817,8 @@ See_Also: $(XREF range,tee)
|
|||
*/
|
||||
template each(alias pred = "a")
|
||||
{
|
||||
import std.meta : TypeTuple;
|
||||
alias BinaryArgs = TypeTuple!(pred, "i", "a");
|
||||
import std.meta : MetaList;
|
||||
alias BinaryArgs = MetaList!(pred, "i", "a");
|
||||
|
||||
enum isRangeUnaryIterable(R) =
|
||||
is(typeof(unaryFun!pred(R.init.front)));
|
||||
|
@ -3756,8 +3756,8 @@ if (isSomeChar!C)
|
|||
@safe pure unittest
|
||||
{
|
||||
import std.algorithm.comparison : equal;
|
||||
import std.meta : TypeTuple;
|
||||
foreach(S; TypeTuple!(string, wstring, dstring))
|
||||
import std.meta : MetaList;
|
||||
foreach(S; MetaList!(string, wstring, dstring))
|
||||
{
|
||||
import std.conv : to;
|
||||
S a = " a bcd ef gh ";
|
||||
|
|
|
@ -736,7 +736,7 @@ unittest
|
|||
{
|
||||
import std.algorithm.iteration : filter;
|
||||
import std.traits : hasElaborateAssign;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
@ -787,7 +787,7 @@ unittest
|
|||
assert (!typeid(S3).init().ptr);
|
||||
assert ( typeid(S4).init().ptr);
|
||||
|
||||
foreach(S; TypeTuple!(S1, S2, S3, S4))
|
||||
foreach(S; MetaList!(S1, S2, S3, S4))
|
||||
{
|
||||
//initializeAll
|
||||
{
|
||||
|
|
|
@ -481,7 +481,7 @@ if (isNarrowString!R1 && isNarrowString!R2)
|
|||
import std.exception : assertThrown;
|
||||
import std.utf : UTFException;
|
||||
import std.range;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
assert(commonPrefix([1, 2, 3], [1, 2, 3, 4, 5]) == [1, 2, 3]);
|
||||
assert(commonPrefix([1, 2, 3, 4, 5], [1, 2, 3]) == [1, 2, 3]);
|
||||
|
@ -492,11 +492,11 @@ if (isNarrowString!R1 && isNarrowString!R2)
|
|||
assert(commonPrefix(cast(int[])null, [1, 2, 3]).empty);
|
||||
assert(commonPrefix(cast(int[])null, cast(int[])null).empty);
|
||||
|
||||
foreach (S; TypeTuple!(char[], const(char)[], string,
|
||||
foreach (S; MetaList!(char[], const(char)[], string,
|
||||
wchar[], const(wchar)[], wstring,
|
||||
dchar[], const(dchar)[], dstring))
|
||||
{
|
||||
foreach(T; TypeTuple!(string, wstring, dstring))
|
||||
foreach(T; MetaList!(string, wstring, dstring))
|
||||
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
|
||||
assert(commonPrefix(to!S(""), to!T("")).empty);
|
||||
assert(commonPrefix(to!S(""), to!T("hello")).empty);
|
||||
|
@ -1065,13 +1065,13 @@ if (isBidirectionalRange!R &&
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.iteration : filterBidirectional;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
import std.conv : to;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
foreach (S; MetaList!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
{
|
||||
assert(!endsWith(to!S("abc"), 'a'));
|
||||
assert(endsWith(to!S("abc"), 'a', 'c') == 2);
|
||||
|
@ -1079,7 +1079,7 @@ if (isBidirectionalRange!R &&
|
|||
assert(endsWith(to!S("abc"), 'x', 'n', 'c') == 3);
|
||||
assert(endsWith(to!S("abc\uFF28"), 'a', '\uFF28', 'c') == 2);
|
||||
|
||||
foreach (T; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
foreach (T; MetaList!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
|
||||
//Lots of strings
|
||||
assert(endsWith(to!S("abc"), to!T("")));
|
||||
|
@ -1113,7 +1113,7 @@ if (isBidirectionalRange!R &&
|
|||
}();
|
||||
}
|
||||
|
||||
foreach (T; TypeTuple!(int, short))
|
||||
foreach (T; MetaList!(int, short))
|
||||
{
|
||||
immutable arr = cast(T[])[0, 1, 2, 3, 4, 5];
|
||||
|
||||
|
@ -1367,10 +1367,10 @@ if (isInputRange!InputRange &&
|
|||
|
||||
@safe pure unittest
|
||||
{
|
||||
import std.meta : TypeTuple;
|
||||
foreach(R; TypeTuple!(string, wstring, dstring))
|
||||
import std.meta : MetaList;
|
||||
foreach(R; MetaList!(string, wstring, dstring))
|
||||
{
|
||||
foreach(E; TypeTuple!(char, wchar, dchar))
|
||||
foreach(E; MetaList!(char, wchar, dchar))
|
||||
{
|
||||
R r1 = "hello world";
|
||||
E e1 = 'w';
|
||||
|
@ -1411,15 +1411,15 @@ if (isInputRange!InputRange &&
|
|||
@safe unittest
|
||||
{
|
||||
import std.exception : assertCTFEable;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
void dg() @safe pure nothrow
|
||||
{
|
||||
byte[] sarr = [1, 2, 3, 4];
|
||||
ubyte[] uarr = [1, 2, 3, 4];
|
||||
foreach(arr; TypeTuple!(sarr, uarr))
|
||||
foreach(arr; MetaList!(sarr, uarr))
|
||||
{
|
||||
foreach(T; TypeTuple!(byte, ubyte, int, uint))
|
||||
foreach(T; MetaList!(byte, ubyte, int, uint))
|
||||
{
|
||||
assert(find(arr, cast(T) 3) == arr[2 .. $]);
|
||||
assert(find(arr, cast(T) 9) == arr[$ .. $]);
|
||||
|
@ -1959,7 +1959,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
@safe unittest
|
||||
{
|
||||
import std.algorithm.internal : rndstuff;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
import std.uni : toUpper;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
|
@ -1969,7 +1969,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
assert(find(a, 5).empty);
|
||||
assert(find(a, 2) == [2, 3]);
|
||||
|
||||
foreach (T; TypeTuple!(int, double))
|
||||
foreach (T; MetaList!(int, double))
|
||||
{
|
||||
auto b = rndstuff!(T)();
|
||||
if (!b.length) continue;
|
||||
|
@ -1992,7 +1992,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
import std.algorithm.internal : rndstuff;
|
||||
import std.algorithm.comparison : equal;
|
||||
import std.range : retro;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
@ -2001,7 +2001,7 @@ if (Ranges.length > 1 && is(typeof(startsWith!pred(haystack, needles))))
|
|||
assert(find(retro(a), 5).empty);
|
||||
assert(equal(find(retro(a), 2), [ 2, 3, 2, 1 ][]));
|
||||
|
||||
foreach (T; TypeTuple!(int, double))
|
||||
foreach (T; MetaList!(int, double))
|
||||
{
|
||||
auto b = rndstuff!(T)();
|
||||
if (!b.length) continue;
|
||||
|
@ -2688,7 +2688,7 @@ unittest
|
|||
unittest
|
||||
{
|
||||
import std.conv : text;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
@ -2738,7 +2738,7 @@ unittest
|
|||
}
|
||||
static assert(!isAssignable!S3);
|
||||
|
||||
foreach (Type; TypeTuple!(S1, IS1, S2, IS2, S3))
|
||||
foreach (Type; MetaList!(S1, IS1, S2, IS2, S3))
|
||||
{
|
||||
static if (is(Type == immutable)) alias V = immutable int;
|
||||
else alias V = int;
|
||||
|
@ -3171,12 +3171,12 @@ if (isInputRange!R &&
|
|||
import std.algorithm.iteration : filter;
|
||||
import std.conv : to;
|
||||
import std.range;
|
||||
import std.meta : TypeTuple;
|
||||
import std.meta : MetaList;
|
||||
|
||||
debug(std_algorithm) scope(success)
|
||||
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
|
||||
|
||||
foreach (S; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
foreach (S; MetaList!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
{
|
||||
assert(!startsWith(to!S("abc"), 'c'));
|
||||
assert(startsWith(to!S("abc"), 'a', 'c') == 1);
|
||||
|
@ -3184,7 +3184,7 @@ if (isInputRange!R &&
|
|||
assert(startsWith(to!S("abc"), 'x', 'n', 'a') == 3);
|
||||
assert(startsWith(to!S("\uFF28abc"), 'a', '\uFF28', 'c') == 2);
|
||||
|
||||
foreach (T; TypeTuple!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
foreach (T; MetaList!(char[], wchar[], dchar[], string, wstring, dstring))
|
||||
(){ // avoid slow optimizations for large functions @@@BUG@@@ 2396
|
||||
//Lots of strings
|
||||
assert(startsWith(to!S("abc"), to!T("")));
|
||||
|
@ -3226,7 +3226,7 @@ if (isInputRange!R &&
|
|||
assert(startsWith("abc".takeExactly(3), "abcd".takeExactly(3)));
|
||||
assert(startsWith("abc".takeExactly(3), "abcd".takeExactly(1)));
|
||||
|
||||
foreach (T; TypeTuple!(int, short))
|
||||
foreach (T; MetaList!(int, short))
|
||||
{
|
||||
immutable arr = cast(T[])[0, 1, 2, 3, 4, 5];
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import std.range.primitives;
|
|||
import std.functional; // : unaryFun, binaryFun;
|
||||
import std.traits;
|
||||
// FIXME
|
||||
import std.meta; // : TypeTuple, staticMap, allSatisfy, anySatisfy;
|
||||
import std.meta; // : MetaList, staticMap, allSatisfy, anySatisfy;
|
||||
|
||||
// cartesianProduct
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue