Replace isInterface, isClass, isStruct with isPolymorphic

This commit is contained in:
Eugen Wissner 2017-10-05 07:12:27 +02:00
parent 7e93bcdeeb
commit 2f4dd34582

View File

@ -275,38 +275,37 @@ pure nothrow @safe @nogc unittest
static assert(!isTemplate!(S!int)); static assert(!isTemplate!(S!int));
} }
/** deprecated("Use is(T == interface) instead")
* Determine whether $(D_PARAM T) is an interface.
*
* Params:
* T = A type.
*
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is an interface,
* $(D_KEYWORD false) otherwise.
*/
enum bool isInterface(T) = is(T == interface); enum bool isInterface(T) = is(T == interface);
/** deprecated("Use is(T == class) instead")
* Determine 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.
*/
enum bool isClass(T) = is(T == class); enum bool isClass(T) = is(T == class);
deprecated("Use is(T == struct) instead")
enum bool isStruct(T) = is(T == struct);
/** /**
* Determine whether $(D_PARAM T) is a struct. * Determines whether $(D_PARAM T) is a polymorphic type, i.e. a
* $(D_KEYWORD class) or an $(D_KEYWORD interface).
* *
* Params: * Params:
* T = A type. * T = A type.
* *
* Returns: $(D_KEYWORD true) if $(D_PARAM T) is a struct, * Returns: $(D_KEYWORD true) if $(D_PARAM T) is a $(D_KEYWORD class) or an
* $(D_KEYWORD false) otherwise. * $(D_KEYWORD interface), $(D_KEYWORD false) otherwise.
*/ */
enum bool isStruct(T) = is(T == struct); enum bool isPolymorphic(T) = is(T == class) || is(T == interface);
///
@nogc nothrow pure @safe unittest
{
interface I
{
}
static assert(isPolymorphic!Object);
static assert(isPolymorphic!I);
static assert(!isPolymorphic!short);
}
/** /**
* Params: * Params: