Phobos should only mention tuple as std.typecons.Tuple

This commit is contained in:
Dicebot 2015-04-29 21:18:46 +03:00
parent 0f74b4c29f
commit a76d90c927
11 changed files with 141 additions and 133 deletions

View file

@ -90,7 +90,7 @@ uint among(alias pred = (a, b) => a == b, Value, Values...)
/// Ditto
template among(values...)
if (isExpressionTuple!values)
if (isExpressionList!values)
{
uint among(Value)(Value value)
if (!is(CommonType!(Value, values) == void))
@ -169,8 +169,8 @@ efficient search, but one that only supports matching on equality:
// in a tuple.
private template indexOfFirstOvershadowingChoiceOnLast(choices...)
{
alias firstParameterTypes = ParameterTypeTuple!(choices[0]);
alias lastParameterTypes = ParameterTypeTuple!(choices[$ - 1]);
alias firstParameterTypes = ParameterTypes!(choices[0]);
alias lastParameterTypes = ParameterTypes!(choices[$ - 1]);
static if (lastParameterTypes.length == 0)
{
@ -254,7 +254,7 @@ auto castSwitch(choices...)(Object switchObject)
static assert(isCallable!choice,
"A choice handler must be callable");
alias choiceParameterTypes = ParameterTypeTuple!choice;
alias choiceParameterTypes = ParameterTypes!choice;
static assert(choiceParameterTypes.length <= 1,
"A choice handler can not have more than one argument.");
@ -270,7 +270,7 @@ auto castSwitch(choices...)(Object switchObject)
static assert(indexOfOvershadowingChoice == index,
"choice number %d(type %s) is overshadowed by choice number %d(type %s)".format(
index + 1, CastClass.stringof, indexOfOvershadowingChoice + 1,
ParameterTypeTuple!(choices[indexOfOvershadowingChoice])[0].stringof));
ParameterTypes!(choices[indexOfOvershadowingChoice])[0].stringof));
if (classInfo == typeid(CastClass))
{
@ -297,7 +297,7 @@ auto castSwitch(choices...)(Object switchObject)
// Checking for derived matches:
foreach (choice; choices)
{
alias choiceParameterTypes = ParameterTypeTuple!choice;
alias choiceParameterTypes = ParameterTypes!choice;
static if (choiceParameterTypes.length == 1)
{
if (auto castedObject = cast(choiceParameterTypes[0]) switchObject)
@ -327,7 +327,7 @@ auto castSwitch(choices...)(Object switchObject)
// Checking for null matches:
foreach (index, choice; choices)
{
static if (ParameterTypeTuple!(choice).length == 0)
static if (ParameterTypes!(choice).length == 0)
{
immutable indexOfOvershadowingChoice =
indexOfFirstOvershadowingChoiceOnLast!(choices[0..index + 1]);

View file

@ -150,7 +150,7 @@ private
auto map(Op)( Op op )
{
alias Args = ParameterTypeTuple!(Op);
alias Args = ParameterTypes!(Op);
static if( Args.length == 1 )
{
@ -171,7 +171,7 @@ private
foreach( i, t1; T )
{
static assert( isFunctionPointer!t1 || isDelegate!t1 );
alias a1 = ParameterTypeTuple!(t1);
alias a1 = ParameterTypes!(t1);
alias r1 = ReturnType!(t1);
static if( i < T.length - 1 && is( r1 == void ) )
@ -183,7 +183,7 @@ private
foreach( t2; T[i+1 .. $] )
{
static assert( isFunctionPointer!t2 || isDelegate!t2 );
alias a2 = ParameterTypeTuple!(t2);
alias a2 = ParameterTypes!(t2);
static assert( !is( a1 == a2 ),
"function with arguments " ~ a1.stringof ~
@ -397,8 +397,8 @@ private template isSpawnable(F, T...)
{
template isParamsImplicitlyConvertible(F1, F2, int i=0)
{
alias param1 = ParameterTypeTuple!F1;
alias param2 = ParameterTypeTuple!F2;
alias param1 = ParameterTypes!F1;
alias param2 = ParameterTypes!F2;
static if (param1.length != param2.length)
enum isParamsImplicitlyConvertible = false;
else static if (param1.length == i)
@ -1920,7 +1920,7 @@ private
{
foreach( i, t; Ops )
{
alias Args = ParameterTypeTuple!(t);
alias Args = ParameterTypes!(t);
auto op = ops[i];
if( msg.convertsTo!(Args) )

View file

@ -1066,7 +1066,7 @@ public:
scope(exit) colIndex++;
if (indices.length > 0)
{
foreach(ti, ToType; FieldTypeTuple!(Contents))
foreach(ti, ToType; FieldTypes!(Contents))
{
if (indices[ti] == colIndex)
{
@ -1077,7 +1077,7 @@ public:
}
else
{
foreach(ti, ToType; FieldTypeTuple!(Contents))
foreach(ti, ToType; FieldTypes!(Contents))
{
if (ti == colIndex)
{

View file

@ -1214,7 +1214,7 @@ unittest
//To check the class payload itself, iterate on its members:
()
{
foreach (index, _; FieldTypeTuple!C)
foreach (index, _; FieldTypes!C)
if (doesPointTo(a.tupleof[index], i))
return;
assert(0);

View file

@ -87,10 +87,10 @@ private template needOpCallAlias(alias fun)
*/
static if (is(typeof(fun.opCall) == function))
{
import std.traits : ParameterTypeTuple;
import std.traits : ParameterTypes;
enum needOpCallAlias = !is(typeof(fun)) && __traits(compiles, () {
return fun(ParameterTypeTuple!fun.init);
return fun(ParameterTypes!fun.init);
});
}
else
@ -659,7 +659,7 @@ template partial(alias fun, alias arg)
{
static if (is(typeof(fun) == delegate) || is(typeof(fun) == function))
{
ReturnType!fun partial(ParameterTypeTuple!fun[1..$] args2)
ReturnType!fun partial(ParameterTypes!fun[1..$] args2)
{
return fun(arg, args2);
}
@ -1024,11 +1024,11 @@ is useful to memoize an impure function, too.
*/
template memoize(alias fun)
{
// alias Args = ParameterTypeTuple!fun; // Bugzilla 13580
// alias Args = ParameterTypes!fun; // Bugzilla 13580
ReturnType!fun memoize(ParameterTypeTuple!fun args)
ReturnType!fun memoize(ParameterTypes!fun args)
{
alias Args = ParameterTypeTuple!fun;
alias Args = ParameterTypes!fun;
import std.typecons : Tuple;
static ReturnType!fun[Tuple!Args] memo;
@ -1042,11 +1042,11 @@ template memoize(alias fun)
/// ditto
template memoize(alias fun, uint maxSize)
{
// alias Args = ParameterTypeTuple!fun; // Bugzilla 13580
ReturnType!fun memoize(ParameterTypeTuple!fun args)
// alias Args = ParameterTypes!fun; // Bugzilla 13580
ReturnType!fun memoize(ParameterTypes!fun args)
{
import std.typecons : tuple;
static struct Value { ParameterTypeTuple!fun args; ReturnType!fun res; }
static struct Value { ParameterTypes!fun args; ReturnType!fun res; }
static Value[] memo;
static size_t[] initialized;
@ -1209,7 +1209,7 @@ private struct DelegateFaker(F)
*--------------------
* struct DelegateFaker(F) {
* extern(linkage)
* [ref] ReturnType!F doIt(ParameterTypeTuple!F args) [@attributes]
* [ref] ReturnType!F doIt(ParameterTypes!F args) [@attributes]
* {
* auto fp = cast(F) &this;
* return fp(args);
@ -1229,7 +1229,7 @@ private struct DelegateFaker(F)
template generateFunctionBody(unused...)
{
enum generateFunctionBody =
// [ref] ReturnType doIt(ParameterTypeTuple args) @attributes
// [ref] ReturnType doIt(ParameterTypes args) @attributes
q{
// When this function gets called, the this pointer isn't
// really a this pointer (no instance even really exists), but

View file

@ -254,7 +254,7 @@ private template isSafeTask(F)
(functionAttributes!F & (FunctionAttribute.safe | FunctionAttribute.trusted)) != 0 &&
(functionAttributes!F & FunctionAttribute.ref_) == 0 &&
(isFunctionPointer!F || !hasUnsharedAliasing!F) &&
std.meta.algorithm.all!(noUnsharedAliasing, ParameterTypeTuple!F);
std.meta.algorithm.all!(noUnsharedAliasing, ParameterTypes!F);
}
unittest
@ -2342,9 +2342,9 @@ public:
*/
auto asyncBuf(C1, C2)(C1 next, C2 empty, size_t initialBufSize = 0, size_t nBuffers = 100)
if(is(typeof(C2.init()) : bool) &&
ParameterTypeTuple!C1.length == 1 &&
ParameterTypeTuple!C2.length == 0 &&
isArray!(ParameterTypeTuple!C1[0])
ParameterTypes!C1.length == 1 &&
ParameterTypes!C2.length == 0 &&
isArray!(ParameterTypes!C1[0])
) {
auto roundRobin = RoundRobinBuffer!(C1, C2)(next, empty, initialBufSize, nBuffers);
return asyncBuf(roundRobin, nBuffers / 2);
@ -3492,7 +3492,7 @@ int doSizeZeroCase(R, Delegate)(ref ParallelForeach!R p, Delegate dg)
{
foreach(ref ElementType!R elem; range)
{
static if(ParameterTypeTuple!dg.length == 2)
static if(ParameterTypes!dg.length == 2)
{
res = dg(index, elem);
}
@ -3508,7 +3508,7 @@ int doSizeZeroCase(R, Delegate)(ref ParallelForeach!R p, Delegate dg)
{
foreach(ElementType!R elem; range)
{
static if(ParameterTypeTuple!dg.length == 2)
static if(ParameterTypes!dg.length == 2)
{
res = dg(index, elem);
}
@ -3532,7 +3532,7 @@ private enum string parallelApplyMixinRandomAccess = q{
}
// Whether iteration is with or without an index variable.
enum withIndex = ParameterTypeTuple!(typeof(dg)).length == 2;
enum withIndex = ParameterTypes!(typeof(dg)).length == 2;
shared size_t workUnitIndex = size_t.max; // Effectively -1: chunkIndex + 1 == 0
immutable len = range.length;
@ -3587,7 +3587,7 @@ enum string parallelApplyMixinInputRange = q{
}
// Whether iteration is with or without an index variable.
enum withIndex = ParameterTypeTuple!(typeof(dg)).length == 2;
enum withIndex = ParameterTypes!(typeof(dg)).length == 2;
// This protects the range while copying it.
auto rangeMutex = new Mutex();
@ -3844,7 +3844,7 @@ private struct RoundRobinBuffer(C1, C2)
{
// No need for constraints because they're already checked for in asyncBuf.
alias Array = ParameterTypeTuple!(C1.init)[0];
alias Array = ParameterTypes!(C1.init)[0];
alias T = typeof(Array.init[0]);
T[][] bufs;

View file

@ -2595,12 +2595,12 @@ $(D Range) that locks the file and allows fast writing to it.
/// ditto
void put(C)(C c) @safe if (is(C : const(dchar)))
{
import std.traits : ParameterTypeTuple;
import std.traits : ParameterTypes;
static auto trustedFPUTC(int ch, _iobuf* h) @trusted
{
return FPUTC(ch, h);
}
static auto trustedFPUTWC(ParameterTypeTuple!FPUTWC[0] ch, _iobuf* h) @trusted
static auto trustedFPUTWC(ParameterTypes!FPUTWC[0] ch, _iobuf* h) @trusted
{
return FPUTWC(ch, h);
}
@ -3656,8 +3656,8 @@ struct lines
// if (fileName.length && fclose(f))
// StdioException("Could not close file `"~fileName~"'");
// }
import std.traits : ParameterTypeTuple;
alias Parms = ParameterTypeTuple!(dg);
import std.traits : ParameterTypes;
alias Parms = ParameterTypes!(dg);
static if (isSomeString!(Parms[$ - 1]))
{
enum bool duplicate = is(Parms[$ - 1] == string)
@ -3702,9 +3702,9 @@ struct lines
{
import std.exception : assumeUnique;
import std.conv : to;
import std.traits : ParameterTypeTuple;
import std.traits : ParameterTypes;
alias Parms = ParameterTypeTuple!(dg);
alias Parms = ParameterTypes!(dg);
enum duplicate = is(Parms[$ - 1] : immutable(ubyte)[]);
int result = 1;
int c = void;

View file

@ -2067,8 +2067,8 @@ auto representation(Char)(Char[] s) @safe pure nothrow @nogc
Tuple!(wchar, ushort),
Tuple!(dchar, uint )))
{
alias Char = FieldTypeTuple!Type[0];
alias Int = FieldTypeTuple!Type[1];
alias Char = FieldTypes!Type[0];
alias Int = FieldTypes!Type[1];
enum immutable(Char)[] hello = "hello";
test!( immutable Char, immutable Int)(hello);

View file

@ -896,9 +896,10 @@ unittest
}
/***
Get, as a $(D MetaList), the types of the parameters to a function, a pointer
to function, a delegate, a struct with an $(D opCall), a pointer to a
struct with an $(D opCall), or a class with an $(D opCall).
Get, as a $(XREF meta.list, MetaList), the types of the parameters to a
function, a pointer to function, a delegate, a struct with
an $(D opCall), a pointer to a struct with an $(D opCall), or a class
with an $(D opCall).
*/
template ParameterTypes(func...)
if (func.length == 1 && isCallable!func)
@ -965,8 +966,8 @@ unittest {
}
/**
Returns a tuple consisting of the storage classes of the parameters of a
function $(D func).
Returns a $(XREF meta.list, MetaList) consisting of the storage classes
off the parameters of a function $(D func).
*/
enum ParameterStorageClass : uint
{
@ -997,7 +998,7 @@ template ParameterStorageClasses(func...)
// chop off CallConvention and FuncAttrs
enum margs = demangleFunctionAttributes(mangledName!Func[1 .. $]).rest;
// demangle Arguments and store parameter storage classes in a tuple
// demangle Arguments and store parameter storage classes in a list
template demangleNextParameter(string margs, size_t i = 0)
{
static if (i < Params.length)
@ -1092,7 +1093,8 @@ unittest
/**
Get, as a tuple, the identifiers of the parameters to a function symbol.
Get, as a $(XREF meta.list, MetaList), the identifiers of the parameters
to a function symbol.
*/
template ParameterIdentifiers(func...)
if (func.length == 1 && isCallable!func)
@ -1181,7 +1183,8 @@ unittest
/**
Get, as a tuple, the default value of the parameters to a function symbol.
Get, as a $(XREF meta.list, MetaList), the default value of the parameters
to a function symbol.
If a parameter doesn't have the default value, $(D void) is returned instead.
*/
template ParameterDefaultValues(func...)
@ -2170,11 +2173,13 @@ unittest
/***
* Get as a typetuple the types of the fields of a struct, class, or union.
* Get as a $(XREF meta.list, MetaList) the types of the fields of a struct,
* class, or union.
*
* This consists of the fields that take up memory space,
* excluding the hidden fields like the virtual function
* table pointer or a context pointer for nested types.
* If $(D T) isn't a struct, class, or union returns typetuple
* If $(D T) isn't a struct, class, or union returns type list
* with one element $(D T).
*/
template FieldTypes(T)
@ -2224,11 +2229,11 @@ unittest
private enum NameOf(alias T) = T.stringof;
/**
* Get as an expression tuple the names of the fields of a struct, class, or
* Get as an expression list the names of the fields of a struct, class, or
* union. This consists of the fields that take up memory space, excluding the
* hidden fields like the virtual function table pointer or a context pointer
* for nested types. If $(D T) isn't a struct, class, or union returns an
* expression tuple with an empty string.
* expression list with an empty string.
*/
template FieldNames(T)
{
@ -3340,13 +3345,13 @@ Params:
E = An enumerated type. $(D E) may have duplicated values.
Returns:
Static tuple composed of the members of the enumerated type $(D E).
Expression list composed of the members of the enumerated type $(D E).
The members are arranged in the same order as declared in $(D E).
Note:
An enum can have multiple members which have the same value. If you want
to use EnumMembers to e.g. generate switch cases at compile-time,
you should use the $(XREF typetuple, NoDuplicates) template to avoid
you should use the $(XREF meta.list, NoDuplicates) template to avoid
generating duplicate switch cases.
Note:
@ -3488,7 +3493,7 @@ unittest
/***
* Get a $(D_PARAM MetaList) of the base class and base interfaces of
* this class or interface. $(D_PARAM BaseTypes!Object) returns
* the empty type tuple.
* the empty type list.
*/
template BaseTypes(A)
{
@ -3533,7 +3538,7 @@ unittest
/**
* Get a $(D_PARAM MetaList) of $(I all) base classes of this class,
* in decreasing order. Interfaces are not included. $(D_PARAM
* BaseClasses!Object) yields the empty type tuple.
* BaseClasses!Object) yields the empty type list.
*/
template BaseClasses(T)
if (is(T == class))
@ -3585,7 +3590,7 @@ unittest
* Get a $(D_PARAM MetaList) of $(I all) interfaces directly or
* indirectly inherited by this class or interface. Interfaces do not
* repeat if multiply implemented. $(D_PARAM Interfaces!Object)
* yields the empty type tuple.
* yields the empty type list.
*/
template Interfaces(T)
{
@ -3648,7 +3653,7 @@ unittest
* Get a $(D_PARAM MetaList) of $(I all) base classes of $(D_PARAM
* T), in decreasing order, followed by $(D_PARAM T)'s
* interfaces. $(D_PARAM TransitiveBaseTypes!Object) yields the
* empty type tuple.
* empty type list.
*/
template TransitiveBaseTypes(T)
{
@ -3683,8 +3688,10 @@ unittest
/**
Returns a tuple of non-static functions with the name $(D name) declared in the
class or interface $(D C). Covariant duplicates are shrunk into the most
Returns a symbol list of non-static functions with the name $(D name)
declared in the class or interface $(D C).
Covariant duplicates are shrunk into the most
derived one.
*/
template MemberFunctions(C, string name)
@ -3724,7 +3731,7 @@ template MemberFunctions(C, string name)
alias MetaList!() CollectOverloads; // no overloads in this hierarchy
}
// duplicates in this tuple will be removed by shrink()
// duplicates in this list will be removed by shrink()
alias CollectOverloads!C overloads;
// shrinkOne!args[0] = the most derived one in the covariant siblings of target
@ -3884,7 +3891,8 @@ unittest
/**
Returns a $(D MetaList) of the template arguments used to instantiate $(D T).
Returns a $(XREF meta.list, MetaList) of the template arguments used
to instantiate $(D T).
*/
template TemplateArgsOf(alias T : Base!Args, alias Base, Args...)
{
@ -4017,7 +4025,7 @@ unittest
/**
* Returns a tuple with all possible target types of an implicit
* Returns a type list with all possible target types of an implicit
* conversion of a value of type $(D_PARAM T).
*
* Important note:
@ -5542,7 +5550,7 @@ unittest
/**
* Check whether $(D T) is an expression list.
* An expression list is kind of compile-time list (also $(D MetaList))
* An expression list is kind of compile-time list (see $(XREF meta.list, MetaList))
* that only contains expressions.
*
* See_Also: $(LREF isTypeList).
@ -5593,7 +5601,7 @@ unittest
/**
* Check whether $(D T) is a type list.
* A type list is kind of compile-time list (also $(D MetaList))
* A type list is kind of compile-time list (see $(XREF meta.list, MetaList))
* that only contains types.
*
* See_Also: $(LREF isExpressionList).

View file

@ -410,7 +410,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, MetaList) iteration), all of which use
loop constructs (e.g. $(XREF meta.list, MetaList) iteration), all of which use
zero-based indexing.
Params:
@ -3203,7 +3203,7 @@ private static:
import std.meta : Filter;
static if (names.length > 0)
{
alias methods = Filter!(pred, MemberFunctionsTuple!(C, names[0]));
alias methods = Filter!(pred, MemberFunctions!(C, names[0]));
alias next = Impl!(names[1 .. $]);
static if (methods.length > 0)
@ -3499,12 +3499,12 @@ Used by MemberFunctionGenerator.
package template FuncInfo(alias func, /+[BUG 4217 ?]+/ T = typeof(&func))
{
alias RT = ReturnType!T;
alias PT = ParameterTypeTuple!T;
alias PT = ParameterTypes!T;
}
package template FuncInfo(Func)
{
alias RT = ReturnType!Func;
alias PT = ParameterTypeTuple!Func;
alias PT = ParameterTypes!Func;
}
/*
@ -3700,7 +3700,7 @@ private static:
/*** Function Body ***/
code ~= "{\n";
{
enum nparams = ParameterTypeTuple!(func).length;
enum nparams = ParameterTypes!(func).length;
/* Declare keywords: args, self and parent. */
string preamble;
@ -3737,7 +3737,7 @@ private static:
private GenParams generateParameters(string myFuncInfo, func...)()
{
alias STC = ParameterStorageClass;
alias stcs = ParameterStorageClassTuple!(func);
alias stcs = ParameterStorageClasses!(func);
enum nparams = stcs.length;
string imports = ""; // any imports required
@ -4032,7 +4032,7 @@ if (Targets.length >= 1 && std.meta.algorithm.all!(isMutable, Targets))
enum n = to!string(i);
static if (fa & FunctionAttribute.property)
{
static if (ParameterTypeTuple!(TargetMembers[i].type).length == 0)
static if (ParameterTypes!(TargetMembers[i].type).length == 0)
enum fbody = "_wrap_source."~name;
else
enum fbody = "_wrap_source."~name~" = forward!args";
@ -4043,7 +4043,7 @@ if (Targets.length >= 1 && std.meta.algorithm.all!(isMutable, Targets))
}
enum generateFun =
"override "~stc~"ReturnType!(TargetMembers["~n~"].type) "
~ name~"(ParameterTypeTuple!(TargetMembers["~n~"].type) args) "~mod~
~ name~"(ParameterTypes!(TargetMembers["~n~"].type) args) "~mod~
"{ return "~fbody~"; }";
}
@ -4340,7 +4340,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 = ParameterTypes!(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))) ||
@ -4452,8 +4452,8 @@ private template DerivedFunctionType(T...)
{
alias FA = FunctionAttribute;
alias F0 = T[0], R0 = ReturnType!F0, PSTC0 = ParameterStorageClassTuple!F0;
alias F1 = T[1], R1 = ReturnType!F1, PSTC1 = ParameterStorageClassTuple!F1;
alias F0 = T[0], R0 = ReturnType!F0, PSTC0 = ParameterStorageClasses!F0;
alias F1 = T[1], R1 = ReturnType!F1, PSTC1 = ParameterStorageClasses!F1;
enum FA0 = functionAttributes!F0;
enum FA1 = functionAttributes!F1;

View file

@ -517,7 +517,7 @@ private:
}
else
{
alias ParamTypes = ParameterTypeTuple!A;
alias ParamTypes = ParameterTypes!A;
auto p = cast(Variant*) parm;
auto argCount = p.get!size_t;
// To assign the tuple we need to use the unqualified version,
@ -1197,7 +1197,7 @@ public:
*/
int opApply(Delegate)(scope Delegate dg) if (is(Delegate == delegate))
{
alias A = ParameterTypeTuple!(Delegate)[0];
alias A = ParameterTypes!(Delegate)[0];
if (type == typeid(A[]))
{
auto arr = get!(A[]);
@ -2207,7 +2207,7 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant
// Handle normal function objects
static if (isSomeFunction!dg)
{
alias Params = ParameterTypeTuple!dg;
alias Params = ParameterTypes!dg;
static if (Params.length == 0)
{
// Just check exception functions in the first