On 3/10/25 2:31 PM, Andy Valencia wrote:

> Is there a static-if
> which can tell if a type is of a struct, as opposed to a class?

[...]

> Something like:
>
>> static if (__traits(isClass, T)) {
>>    ...
>> } else if (__traits(isStruct, T)) {
>>    ...
>> } else {
>>    (failure)
>> }
>
> Thanks,
> Andy
>

You would expect that to be provided by one of the following:

  https://dlang.org/phobos/std_traits.html

  https://dlang.org/spec/traits.html

But in this case it's the "is expression":

  https://dlang.org/spec/expression.html#is_expression

static assert (is (S == struct));

Ali

Reply via email to