Remove deprecated traits and queue
This commit is contained in:
@@ -44,7 +44,7 @@ import tanya.meta.transform;
|
||||
* See_Also: $(D_PSYMBOL isLess).
|
||||
*/
|
||||
template Min(alias pred, Args...)
|
||||
if (Args.length > 0 && isTemplate!pred)
|
||||
if (Args.length > 0 && __traits(isTemplate, pred))
|
||||
{
|
||||
static if (Args.length == 1)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ if (Args.length > 0 && isTemplate!pred)
|
||||
* See_Also: $(D_PSYMBOL isLess).
|
||||
*/
|
||||
template Max(alias pred, Args...)
|
||||
if (Args.length > 0 && isTemplate!pred)
|
||||
if (Args.length > 0 && __traits(isTemplate, pred))
|
||||
{
|
||||
static if (Args.length == 1)
|
||||
{
|
||||
@@ -148,7 +148,7 @@ if (Args.length > 0 && isTemplate!pred)
|
||||
*/
|
||||
template ZipWith(alias f, Tuples...)
|
||||
if (Tuples.length > 0
|
||||
&& isTemplate!f
|
||||
&& __traits(isTemplate, f)
|
||||
&& allSatisfy!(ApplyLeft!(isInstanceOf, Tuple), Tuples))
|
||||
{
|
||||
private template GetIth(size_t i, Args...)
|
||||
@@ -448,7 +448,7 @@ if (isInstanceOf!(Set, S1) && isInstanceOf!(Set, S2))
|
||||
* to $(D_INLINECODE Args[1]), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template isLessEqual(alias cmp, Args...)
|
||||
if (Args.length == 2 && isTemplate!cmp)
|
||||
if (Args.length == 2 && __traits(isTemplate, cmp))
|
||||
{
|
||||
private enum result = cmp!(Args[1], Args[0]);
|
||||
static if (is(typeof(result) == bool))
|
||||
@@ -495,7 +495,7 @@ if (Args.length == 2 && isTemplate!cmp)
|
||||
* equal to $(D_INLINECODE Args[1]), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template isGreaterEqual(alias cmp, Args...)
|
||||
if (Args.length == 2 && isTemplate!cmp)
|
||||
if (Args.length == 2 && __traits(isTemplate, cmp))
|
||||
{
|
||||
private enum result = cmp!Args;
|
||||
static if (is(typeof(result) == bool))
|
||||
@@ -542,7 +542,7 @@ if (Args.length == 2 && isTemplate!cmp)
|
||||
* $(D_INLINECODE Args[1]), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template isLess(alias cmp, Args...)
|
||||
if (Args.length == 2 && isTemplate!cmp)
|
||||
if (Args.length == 2 && __traits(isTemplate, cmp))
|
||||
{
|
||||
private enum result = cmp!Args;
|
||||
static if (is(typeof(result) == bool))
|
||||
@@ -589,7 +589,7 @@ if (Args.length == 2 && isTemplate!cmp)
|
||||
* $(D_INLINECODE Args[1]), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template isGreater(alias cmp, Args...)
|
||||
if (Args.length == 2 && isTemplate!cmp)
|
||||
if (Args.length == 2 && __traits(isTemplate, cmp))
|
||||
{
|
||||
private enum result = cmp!Args;
|
||||
static if (is(typeof(result) == bool))
|
||||
@@ -637,7 +637,7 @@ if (Args.length == 2)
|
||||
{
|
||||
static if ((is(typeof(Args[0] == Args[1])) && (Args[0] == Args[1]))
|
||||
|| (isTypeTuple!Args && is(Args[0] == Args[1]))
|
||||
|| isSame!Args)
|
||||
|| __traits(isSame, Args[0], Args[1]))
|
||||
{
|
||||
enum bool isEqual = true;
|
||||
}
|
||||
@@ -804,7 +804,7 @@ alias AliasSeq(Args...) = Args;
|
||||
* $(D_PARAM F), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template allSatisfy(alias F, L...)
|
||||
if (isTemplate!F)
|
||||
if (__traits(isTemplate, F))
|
||||
{
|
||||
static if (L.length == 0)
|
||||
{
|
||||
@@ -842,7 +842,7 @@ if (isTemplate!F)
|
||||
* $(D_PARAM F), $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
template anySatisfy(alias F, L...)
|
||||
if (isTemplate!F)
|
||||
if (__traits(isTemplate, F))
|
||||
{
|
||||
static if (L.length == 0)
|
||||
{
|
||||
@@ -945,6 +945,32 @@ template canFind(alias T, L...)
|
||||
static assert(canFind!(3, () {}, uint, 5, 3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests whether $(D_PARAM T) is a template.
|
||||
*
|
||||
* $(D_PSYMBOL isTemplate) isn't $(D_KEYWORD true) for template instances,
|
||||
* since the latter already represent some type. Only not instantiated
|
||||
* templates, i.e. that accept some template parameters, are considered
|
||||
* templates.
|
||||
*
|
||||
* Params:
|
||||
* T = A symbol.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a template,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
private enum bool isTemplate(alias T) = __traits(isTemplate, T);
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static struct S(T)
|
||||
{
|
||||
}
|
||||
static assert(isTemplate!S);
|
||||
static assert(!isTemplate!(S!int));
|
||||
}
|
||||
|
||||
/**
|
||||
* Combines multiple templates with logical AND. So $(D_PSYMBOL templateAnd)
|
||||
* evaluates to $(D_INLINECODE Preds[0] && Preds[1] && Preds[2]) and so on.
|
||||
@@ -1049,7 +1075,7 @@ if (allSatisfy!(isTemplate, Preds))
|
||||
* Returns: Negated $(D_PARAM pred).
|
||||
*/
|
||||
template templateNot(alias pred)
|
||||
if (isTemplate!pred)
|
||||
if (__traits(isTemplate, pred))
|
||||
{
|
||||
enum bool templateNot(T...) = !pred!T;
|
||||
}
|
||||
@@ -1083,7 +1109,7 @@ if (isTemplate!pred)
|
||||
* if not.
|
||||
*/
|
||||
template isSorted(alias cmp, L...)
|
||||
if (isTemplate!cmp)
|
||||
if (__traits(isTemplate, cmp))
|
||||
{
|
||||
static if (L.length <= 1)
|
||||
{
|
||||
@@ -1359,7 +1385,7 @@ template Reverse(L...)
|
||||
* Returns: Elements $(D_PARAM T) after applying $(D_PARAM F) to them.
|
||||
*/
|
||||
template Map(alias F, T...)
|
||||
if (isTemplate!F)
|
||||
if (__traits(isTemplate, F))
|
||||
{
|
||||
static if (T.length == 0)
|
||||
{
|
||||
@@ -1401,7 +1427,7 @@ if (isTemplate!F)
|
||||
* See_Also: $(LINK2 https://en.wikipedia.org/wiki/Merge_sort, Merge sort).
|
||||
*/
|
||||
template Sort(alias cmp, L...)
|
||||
if (isTemplate!cmp)
|
||||
if (__traits(isTemplate, cmp))
|
||||
{
|
||||
private template merge(size_t A, size_t B)
|
||||
{
|
||||
|
||||
@@ -150,137 +150,7 @@ enum bool isComplex(T) = is(Unqual!(OriginalType!T) == cfloat)
|
||||
static assert(!isComplex!real);
|
||||
}
|
||||
|
||||
/**
|
||||
* POD (Plain Old Data) is a $(D_KEYWORD struct) without constructors,
|
||||
* destructors and member functions.
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a POD type,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use __traits(isPOD) instead")
|
||||
enum bool isPOD(T) = __traits(isPOD, T);
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
struct S1
|
||||
{
|
||||
void method()
|
||||
{
|
||||
}
|
||||
}
|
||||
static assert(!isPOD!S1);
|
||||
|
||||
struct S2
|
||||
{
|
||||
void function() val; // Function pointer, not a member function.
|
||||
}
|
||||
static assert(isPOD!S2);
|
||||
|
||||
struct S3
|
||||
{
|
||||
this(this)
|
||||
{
|
||||
}
|
||||
}
|
||||
static assert(!isPOD!S3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns size of the type $(D_PARAM T).
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: Size of the type $(D_PARAM T).
|
||||
*/
|
||||
deprecated("Use T.sizeof instead")
|
||||
enum size_t sizeOf(T) = T.sizeof;
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(sizeOf!(bool function()) == size_t.sizeof);
|
||||
static assert(sizeOf!bool == 1);
|
||||
static assert(sizeOf!short == 2);
|
||||
static assert(sizeOf!int == 4);
|
||||
static assert(sizeOf!long == 8);
|
||||
static assert(sizeOf!(void[16]) == 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alignment of the type $(D_PARAM T).
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: Alignment of the type $(D_PARAM T).
|
||||
*/
|
||||
deprecated("Use T.alignof instead")
|
||||
enum size_t alignOf(T) = T.alignof;
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(alignOf!bool == bool.alignof);
|
||||
static assert(is(typeof(alignOf!bool) == typeof(bool.alignof)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether $(D_INLINECODE Args[0]) and $(D_INLINECODE Args[1]) are the
|
||||
* same symbol.
|
||||
*
|
||||
* Params:
|
||||
* Args = Two symbols to be tested.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM Args) are the same symbol,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use __traits(isSame) instead")
|
||||
template isSame(Args...)
|
||||
if (Args.length == 2)
|
||||
{
|
||||
enum bool isSame = __traits(isSame, Args[0], Args[1]);
|
||||
}
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static assert(isSame!("string", "string"));
|
||||
static assert(!isSame!(string, immutable(char)[]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether $(D_PARAM T) is a template.
|
||||
*
|
||||
* $(D_PSYMBOL isTemplate) isn't $(D_KEYWORD true) for template instances,
|
||||
* since the latter already represent some type. Only not instantiated
|
||||
* templates, i.e. that accept some template parameters, are considered
|
||||
* templates.
|
||||
*
|
||||
* Params:
|
||||
* T = A symbol.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a template,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use __traits(isTemplate) instead")
|
||||
enum bool isTemplate(alias T) = __traits(isTemplate, T);
|
||||
|
||||
///
|
||||
@nogc nothrow pure @safe unittest
|
||||
{
|
||||
static struct S(T)
|
||||
{
|
||||
}
|
||||
static assert(isTemplate!S);
|
||||
static assert(!isTemplate!(S!int));
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Tests whether $(D_PARAM T) is an interface.
|
||||
*
|
||||
* Params:
|
||||
@@ -289,44 +159,7 @@ enum bool isTemplate(alias T) = __traits(isTemplate, T);
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is an interface,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use is(T == interface) instead")
|
||||
enum bool isInterface(T) = is(T == interface);
|
||||
|
||||
/**
|
||||
* Tests whether $(D_PARAM T) is a class.
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a class,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use is(T == class) instead")
|
||||
enum bool isClass(T) = is(T == class);
|
||||
|
||||
/**
|
||||
* Tests whether $(D_PARAM T) is a struct.
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a struct,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use is(T == struct) instead")
|
||||
enum bool isStruct(T) = is(T == struct);
|
||||
|
||||
/**
|
||||
* Tests whether $(D_PARAM T) is a enum.
|
||||
*
|
||||
* Params:
|
||||
* T = A type.
|
||||
*
|
||||
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is an enum,
|
||||
* $(D_KEYWORD false) otherwise.
|
||||
*/
|
||||
deprecated("Use is(T == enum) instead")
|
||||
enum bool isEnum(T) = is(T == enum);
|
||||
private enum bool isInterface(T) = is(T == interface);
|
||||
|
||||
/**
|
||||
* Determines whether $(D_PARAM T) is a polymorphic type, i.e. a
|
||||
@@ -2007,17 +1840,17 @@ alias TemplateOf(alias T : Base!Args, alias Base, Args...) = Base;
|
||||
static struct S(T)
|
||||
{
|
||||
}
|
||||
static assert(isSame!(TemplateOf!(S!int), S));
|
||||
static assert(__traits(isSame, TemplateOf!(S!int), S));
|
||||
|
||||
static void func(T)()
|
||||
{
|
||||
}
|
||||
static assert(isSame!(TemplateOf!(func!int), func));
|
||||
static assert(__traits(isSame, TemplateOf!(func!int), func));
|
||||
|
||||
template T(U)
|
||||
{
|
||||
}
|
||||
static assert(isSame!(TemplateOf!(T!int), T));
|
||||
static assert(__traits(isSame, TemplateOf!(T!int), T));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2049,7 +1882,7 @@ template isInstanceOf(alias T, alias I)
|
||||
{
|
||||
static if (is(typeof(TemplateOf!I)))
|
||||
{
|
||||
enum bool isInstanceOf = isSame!(TemplateOf!I, T);
|
||||
enum bool isInstanceOf = __traits(isSame, TemplateOf!I, T);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -701,7 +701,7 @@ alias TypeOf(T) = T;
|
||||
|
||||
/// ditto
|
||||
template TypeOf(alias T)
|
||||
if (isExpressions!T || isTemplate!T)
|
||||
if (isExpressions!T || __traits(isTemplate, T))
|
||||
{
|
||||
alias TypeOf = typeof(T);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user