[Issue 21805] New: Allow trinary expression in types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 6 16:15:16 UTC 2021


          Issue ID: 21805
           Summary: Allow trinary expression in types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: qs.il.paperinik at gmail.com

    expr ? type1 : type2
where a type is expected.

+   ConditionalType
    TypeCtors[opt] BasicType TypeSuffixes[opt]

+ ConditionalType:
+   OrOrExpression ? BasicType : ConditionalType

Some small conditions don't warrant 4 (or 8) LoC for defining an alias.

    static if (bits > 32)
        alias Word = ulong;
        alias Word = uint;


    alias Word = bits > 32 ? ulong : uint;

Another win is you can use the conditional type without having to define an


More information about the Digitalmars-d-bugs mailing list