diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-10-05 07:12:27 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-10-05 07:12:27 +0200 |
| commit | 2f4dd345827fee075cbb848c9e78fed39b9cbb54 (patch) | |
| tree | e98014555769f29b4f9e58bf14f8a448891518bb | |
| parent | 7e93bcdeeb985e900bfc4f5a0f87fca5d09a3850 (diff) | |
| download | tanya-2f4dd345827fee075cbb848c9e78fed39b9cbb54.tar.gz | |
Replace isInterface, isClass, isStruct with isPolymorphic
| -rw-r--r-- | source/tanya/meta/trait.d | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/source/tanya/meta/trait.d b/source/tanya/meta/trait.d index bf46fb3..956223e 100644 --- a/source/tanya/meta/trait.d +++ b/source/tanya/meta/trait.d @@ -275,38 +275,37 @@ pure nothrow @safe @nogc unittest static assert(!isTemplate!(S!int)); } -/** - * 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. - */ +deprecated("Use is(T == interface) instead") enum bool isInterface(T) = is(T == interface); -/** - * 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. - */ +deprecated("Use is(T == class) instead") 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: * T = A type. * - * Returns: $(D_KEYWORD true) if $(D_PARAM T) is a struct, - * $(D_KEYWORD false) otherwise. + * Returns: $(D_KEYWORD true) if $(D_PARAM T) is a $(D_KEYWORD class) or an + * $(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: |
