Remove obsolete TypeTuple references

Replace following names:
std.typetuple      -> std.meta
TypeTuple          -> AliasSeq
ParameterTypeTuple -> Parameters
FieldTypeTuple     -> Fields

std.traits requires more work than search/replace and is left unchanged.
This commit is contained in:
Dragos Carp 2015-10-13 20:30:32 +02:00
parent 8d9d606ef8
commit d698887729
48 changed files with 643 additions and 645 deletions

View file

@ -43,9 +43,9 @@ Authors: $(WEB erdani.org, Andrei Alexandrescu),
Kenji Hara
*/
module std.typecons;
import std.meta; // : AliasSeq, allSatisfy;
import std.traits;
// FIXME
import std.typetuple; // : TypeTuple, allSatisfy;
debug(Unique) import std.stdio;
@ -302,7 +302,7 @@ for the second, and so on.
The choice of zero-based indexing instead of one-base indexing was
motivated by the ability to use value `Tuple`s with various compile-time
loop constructs (e.g. $(XREF typetuple, TypeTuple) iteration), all of which use
loop constructs (e.g. $(XREF meta, AliasSeq) iteration), all of which use
zero-based indexing.
Params:
@ -310,7 +310,7 @@ Params:
*/
template Tuple(Specs...)
{
import std.typetuple : staticMap;
import std.meta : staticMap;
// Parse (type,name) pairs (FieldSpecs) out of the specified
// arguments. Some fields would have name, others not.
@ -318,21 +318,21 @@ template Tuple(Specs...)
{
static if (Specs.length == 0)
{
alias parseSpecs = TypeTuple!();
alias parseSpecs = AliasSeq!();
}
else static if (is(Specs[0]))
{
static if (is(typeof(Specs[1]) : string))
{
alias parseSpecs =
TypeTuple!(FieldSpec!(Specs[0 .. 2]),
parseSpecs!(Specs[2 .. $]));
AliasSeq!(FieldSpec!(Specs[0 .. 2]),
parseSpecs!(Specs[2 .. $]));
}
else
{
alias parseSpecs =
TypeTuple!(FieldSpec!(Specs[0]),
parseSpecs!(Specs[1 .. $]));
AliasSeq!(FieldSpec!(Specs[0]),
parseSpecs!(Specs[1 .. $]));
}
}
else
@ -385,11 +385,11 @@ template Tuple(Specs...)
{
static if (spec.name.length == 0)
{
alias expandSpec = TypeTuple!(spec.Type);
alias expandSpec = AliasSeq!(spec.Type);
}
else
{
alias expandSpec = TypeTuple!(spec.Type, spec.name);
alias expandSpec = AliasSeq!(spec.Type, spec.name);
}
}
@ -438,7 +438,7 @@ template Tuple(Specs...)
unittest
{
alias Fields = Tuple!(int, "id", string, float);
static assert(is(Fields.Types == TypeTuple!(int, string, float)));
static assert(is(Fields.Types == AliasSeq!(int, string, float)));
}
/**
@ -450,7 +450,7 @@ template Tuple(Specs...)
unittest
{
alias Fields = Tuple!(int, "id", string, float);
static assert(Fields.fieldNames == TypeTuple!("id", "", ""));
static assert(Fields.fieldNames == AliasSeq!("id", "", ""));
}
/**
@ -851,7 +851,7 @@ unittest
ReverseTupleType!T reverse(T)(T t)
if (isTuple!T)
{
import std.typetuple : Reverse;
import std.meta : Reverse;
// @@@BUG@@@ Cannot be an internal function due to forward reference issues.
// @@@BUG@@@ 9929 Need 'this' when calling template with expanded tuple
@ -885,11 +885,11 @@ private template ReverseTupleSpecs(T...)
{
static if (is(typeof(T[$-1]) : string))
{
alias ReverseTupleSpecs = TypeTuple!(T[$-2], T[$-1], ReverseTupleSpecs!(T[0 .. $-2]));
alias ReverseTupleSpecs = AliasSeq!(T[$-2], T[$-1], ReverseTupleSpecs!(T[0 .. $-2]));
}
else
{
alias ReverseTupleSpecs = TypeTuple!(T[$-1], ReverseTupleSpecs!(T[0 .. $-1]));
alias ReverseTupleSpecs = AliasSeq!(T[$-1], ReverseTupleSpecs!(T[0 .. $-1]));
}
}
else
@ -1158,8 +1158,8 @@ unittest
inout V wv; // OK <- NG
inout const V wcv; // OK <- NG
foreach (v1; TypeTuple!(mv, cv, iv, wv, wcv))
foreach (v2; TypeTuple!(mv, cv, iv, wv, wcv))
foreach (v1; AliasSeq!(mv, cv, iv, wv, wcv))
foreach (v2; AliasSeq!(mv, cv, iv, wv, wcv))
{
static assert(__traits(compiles, v1 < v2),
typeof(v1).stringof ~ " < " ~ typeof(v2).stringof);
@ -1243,7 +1243,7 @@ unittest
static assert(T.fieldNames[1] == "foo");
alias Fields = Tuple!(int, "id", string, float);
static assert(Fields.fieldNames == TypeTuple!("id", "", ""));
static assert(Fields.fieldNames == AliasSeq!("id", "", ""));
}
// Bugzilla 13837
@ -1339,12 +1339,12 @@ template tuple(Names...)
{
template and(B...) if (B.length == 1)
{
alias TypeTuple!(A[0], B[0]) and;
alias AliasSeq!(A[0], B[0]) and;
}
template and(B...) if (B.length != 1)
{
alias TypeTuple!(A[0], B[0],
alias AliasSeq!(A[0], B[0],
Interleave!(A[1..$]).and!(B[1..$])) and;
}
}
@ -1629,7 +1629,7 @@ unittest
immutable(char[]) s7654;
Rebindable!(typeof(s7654)) r7654 = s7654;
foreach (T; TypeTuple!(char, wchar, char, int))
foreach (T; AliasSeq!(char, wchar, char, int))
{
static assert(is(Rebindable!(immutable(T[])) == immutable(T)[]));
static assert(is(Rebindable!(const(T[])) == const(T)[]));
@ -2160,7 +2160,7 @@ unittest
ni = other.ni;
}
}
foreach (S; TypeTuple!(S1, S2))
foreach (S; AliasSeq!(S1, S2))
{
S a;
S b = a;
@ -2531,7 +2531,7 @@ unittest
ni = other.ni;
}
}
foreach (S; TypeTuple!(S1, S2))
foreach (S; AliasSeq!(S1, S2))
{
S a;
S b = a;
@ -2833,7 +2833,7 @@ unittest
ni = other.ni;
}
}
foreach (S; TypeTuple!(S1, S2))
foreach (S; AliasSeq!(S1, S2))
{
S a;
S b = a;
@ -3137,19 +3137,19 @@ private static:
{
template Impl(names...)
{
import std.typetuple : Filter;
import std.meta : Filter;
static if (names.length > 0)
{
alias methods = Filter!(pred, MemberFunctionsTuple!(C, names[0]));
alias next = Impl!(names[1 .. $]);
static if (methods.length > 0)
alias Impl = TypeTuple!(OverloadSet!(names[0], methods), next);
alias Impl = AliasSeq!(OverloadSet!(names[0], methods), next);
else
alias Impl = next;
}
else
alias Impl = TypeTuple!();
alias Impl = AliasSeq!();
}
alias enumerateOverloads = Impl!(__traits(allMembers, C));
@ -3436,13 +3436,13 @@ Used by MemberFunctionGenerator.
*/
package template FuncInfo(alias func, /+[BUG 4217 ?]+/ T = typeof(&func))
{
alias RT = ReturnType!T;
alias PT = ParameterTypeTuple!T;
alias RT = ReturnType!T;
alias PT = Parameters!T;
}
package template FuncInfo(Func)
{
alias RT = ReturnType!Func;
alias PT = ParameterTypeTuple!Func;
alias RT = ReturnType!Func;
alias PT = Parameters!Func;
}
/*
@ -3502,9 +3502,9 @@ private static:
template CountUp(size_t n)
{
static if (n > 0)
alias CountUp = TypeTuple!(CountUp!(n - 1), n - 1);
alias CountUp = AliasSeq!(CountUp!(n - 1), n - 1);
else
alias CountUp = TypeTuple!();
alias CountUp = AliasSeq!();
}
@ -3638,12 +3638,12 @@ private static:
/*** Function Body ***/
code ~= "{\n";
{
enum nparams = ParameterTypeTuple!(func).length;
enum nparams = Parameters!(func).length;
/* Declare keywords: args, self and parent. */
string preamble;
preamble ~= "alias args = TypeTuple!(" ~ enumerateParameters!(nparams) ~ ");\n";
preamble ~= "alias args = AliasSeq!(" ~ enumerateParameters!(nparams) ~ ");\n";
if (!isCtor)
{
preamble ~= "alias self = " ~ name ~ ";\n";
@ -3822,7 +3822,7 @@ unittest
template wrap(Targets...)
if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
{
import std.typetuple : staticMap;
import std.meta : staticMap;
// strict upcast
auto wrap(Source)(inout Source src) @trusted pure nothrow
@ -3856,17 +3856,17 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
template Concat(size_t i = 0)
{
static if (i >= Targets.length)
alias Concat = TypeTuple!();
alias Concat = AliasSeq!();
else
{
alias Concat = TypeTuple!(GetOverloadedMethods!(Targets[i]), Concat!(i + 1));
alias Concat = AliasSeq!(GetOverloadedMethods!(Targets[i]), Concat!(i + 1));
}
}
// Remove duplicated functions based on the identifier name and function type covariance
template Uniq(members...)
{
static if (members.length == 0)
alias Uniq = TypeTuple!();
alias Uniq = AliasSeq!();
else
{
alias func = members[0];
@ -3894,14 +3894,14 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
!is(DerivedFunctionType!(typex, remain[0].type) == void))
{
alias F = DerivedFunctionType!(typex, remain[0].type);
alias Uniq = TypeTuple!(FuncInfo!(name, F), remain[1 .. $]);
alias Uniq = AliasSeq!(FuncInfo!(name, F), remain[1 .. $]);
}
else
alias Uniq = TypeTuple!(FuncInfo!(name, typex), remain);
alias Uniq = AliasSeq!(FuncInfo!(name, typex), remain);
}
else
{
alias Uniq = TypeTuple!(FuncInfo!(name, type), Uniq!(members[1 .. $]));
alias Uniq = AliasSeq!(FuncInfo!(name, type), Uniq!(members[1 .. $]));
}
}
}
@ -3955,7 +3955,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
}
static @property mod()
{
alias type = TypeTuple!(TargetMembers[i].type)[0];
alias type = AliasSeq!(TargetMembers[i].type)[0];
string r;
static if (is(type == immutable)) r ~= " immutable";
else
@ -3970,7 +3970,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
enum n = to!string(i);
static if (fa & FunctionAttribute.property)
{
static if (ParameterTypeTuple!(TargetMembers[i].type).length == 0)
static if (Parameters!(TargetMembers[i].type).length == 0)
enum fbody = "_wrap_source."~name;
else
enum fbody = "_wrap_source."~name~" = forward!args";
@ -3981,7 +3981,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
}
enum generateFun =
"override "~stc~"ReturnType!(TargetMembers["~n~"].type) "
~ name~"(ParameterTypeTuple!(TargetMembers["~n~"].type) args) "~mod~
~ name~"(Parameters!(TargetMembers["~n~"].type) args) "~mod~
"{ return "~fbody~"; }";
}
@ -3995,7 +3995,7 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
template wrap(Targets...)
if (Targets.length >= 1 && !allSatisfy!(isMutable, Targets))
{
import std.typetuple : staticMap;
import std.meta : staticMap;
alias wrap = .wrap!(staticMap!(Unqual, Targets));
}
@ -4229,14 +4229,14 @@ unittest
// Make a tuple of non-static function symbols
private template GetOverloadedMethods(T)
{
import std.typetuple : Filter;
import std.meta : Filter;
alias allMembers = TypeTuple!(__traits(allMembers, T));
alias allMembers = AliasSeq!(__traits(allMembers, T));
template follows(size_t i = 0)
{
static if (i >= allMembers.length)
{
alias follows = TypeTuple!();
alias follows = AliasSeq!();
}
else static if (!__traits(compiles, mixin("T."~allMembers[i])))
{
@ -4253,8 +4253,8 @@ private template GetOverloadedMethods(T)
else
enum isMethod = false;
}
alias follows = TypeTuple!(
std.typetuple.Filter!(isMethod, __traits(getOverloads, T, name)),
alias follows = AliasSeq!(
std.meta.Filter!(isMethod, __traits(getOverloads, T, name)),
follows!(i + 1));
}
}
@ -4278,7 +4278,7 @@ private template findCovariantFunction(alias finfo, Source, Fs...)
enum x = check!();
static if (x == -1 && is(typeof(Source.opDispatch)))
{
alias Params = ParameterTypeTuple!(finfo.type);
alias Params = Parameters!(finfo.type);
enum ptrdiff_t findCovariantFunction =
is(typeof(( Source).init.opDispatch!(finfo.name)(Params.init))) ||
is(typeof(( const Source).init.opDispatch!(finfo.name)(Params.init))) ||
@ -4480,17 +4480,17 @@ package template staticIota(int beg, int end)
{
static if (beg >= end)
{
alias staticIota = TypeTuple!();
alias staticIota = AliasSeq!();
}
else
{
alias staticIota = TypeTuple!(+beg);
alias staticIota = AliasSeq!(+beg);
}
}
else
{
enum mid = beg + (end - beg) / 2;
alias staticIota = TypeTuple!(staticIota!(beg, mid), staticIota!(mid, end));
alias staticIota = AliasSeq!(staticIota!(beg, mid), staticIota!(mid, end));
}
}
@ -5250,7 +5250,7 @@ unittest
static immutable arr = [1,2,3];
}
foreach (T; TypeTuple!(MyInt, const MyInt, immutable MyInt))
foreach (T; AliasSeq!(MyInt, const MyInt, immutable MyInt))
{
T m = 10;
static assert(!__traits(compiles, { int x = m; }));
@ -5295,7 +5295,7 @@ unittest
this(immutable int[] arr) immutable { value = arr; }
}
foreach (T; TypeTuple!(MyArray, const MyArray, immutable MyArray))
foreach (T; AliasSeq!(MyArray, const MyArray, immutable MyArray))
{
static if (is(T == immutable) && !is(typeof({ T a = [1,2,3,4]; })))
T a = [1,2,3,4].idup; // workaround until qualified ctor is properly supported
@ -6027,7 +6027,7 @@ unittest // Issue 6580 testcase
byte[size] arr;
alignmentTest();
}
foreach(i; TypeTuple!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
foreach(i; AliasSeq!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
test!i();
}
}
@ -6692,12 +6692,12 @@ template ReplaceType(From, To, T...)
}
else static if (T.length > 1)
{
alias ReplaceType = TypeTuple!(ReplaceType!(From, To, T[0]),
alias ReplaceType = AliasSeq!(ReplaceType!(From, To, T[0]),
ReplaceType!(From, To, T[1 .. $]));
}
else
{
alias ReplaceType = TypeTuple!();
alias ReplaceType = AliasSeq!();
}
}