From aa16e2d99af79c27e518ff1bbbc00eaafeff8a68 Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Sat, 12 Sep 2020 14:38:26 -0400 Subject: [PATCH] Streamline std.traits.AliasThisTypeOf Faster and uses less memory. --- std/traits.d | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/std/traits.d b/std/traits.d index 9370d3399..d6794855f 100644 --- a/std/traits.d +++ b/std/traits.d @@ -5659,17 +5659,7 @@ Note: Trying to use returned value will result in a // SomethingTypeOf //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::// -private template AliasThisTypeOf(T) -{ - alias members = __traits(getAliasThis, T); - - static if (members.length == 1) - { - alias AliasThisTypeOf = typeof(__traits(getMember, T.init, members[0])); - } - else - static assert(0, T.stringof~" does not have alias this type"); -} +private alias AliasThisTypeOf(T) = typeof(__traits(getMember, T.init, __traits(getAliasThis, T)[0])); /* */