digitalmars.D.learn - Trait to identify if a type is a struct one
- pham (11/11) Oct 18 2017 Is there a way to identify if a type is a struct, something like
- drug (5/20) Oct 18 2017 if (is(X == struct))
- user1234 (6/27) Oct 18 2017 static if (is(X == struct))
- =?UTF-8?Q?Ali_=c3=87ehreli?= (9/39) Oct 18 2017 Playing the devil's advocate, I think drug meant it as a function
Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type is a class regardless? something like isClass? Thanks Pham
Oct 18 2017
18.10.2017 18:11, pham пишет:Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type is a class regardless? something like isClass? Thanks Phamif (is(X == struct)) { ... }
Oct 18 2017
On Wednesday, 18 October 2017 at 15:16:21 UTC, drug wrote:18.10.2017 18:11, pham пишет:static if (is(X == struct)) { ... } ptherwise lots of strnage errors ;)Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type is a class regardless? something like isClass? Thanks Phamif (is(X == struct)) { ... }
Oct 18 2017
On 10/18/2017 10:05 AM, user1234 wrote:On Wednesday, 18 October 2017 at 15:16:21 UTC, drug wrote:Playing the devil's advocate, I think drug meant it as a function template constraint. :o) void foo(X)(X x) if (is(X == struct)) { // ... } Ali18.10.2017 18:11, pham пишет:static if (is(X == struct)) { ... } ptherwise lots of strnage errors ;)Is there a way to identify if a type is a struct, something like isStruct similar to isArray. struct X { } isStruct!X == true? Also, there are isAbstractClass & isFinalClass but want to check if type is a class regardless? something like isClass? Thanks Phamif (is(X == struct)) { ... }
Oct 18 2017