Struct and union declarations.

Specification: Structs, Unions


Walter Bright

Source: dstruct.d

  • Declaration

    FuncDeclaration search_toString(StructDeclaration sd);

    Search sd for a member function of the form: extern (D) string toString();


    StructDeclaration sd

    struct declaration to search

    Return Value

    FuncDeclaration of toString() if found, null if not

  • Declaration

    void semanticTypeInfo(Scope* sc, Type t);

    Request additional semantic analysis for TypeInfo generation.


    Scope* sc


    Type t

    type that TypeInfo is being generated for

  • Declaration

    class StructDeclaration: dmd.aggregate.AggregateDeclaration;

    All struct declarations are an instance of this.

    • fit


      final bool fit(ref const Loc loc, Scope* sc, Expressions* elements, Type stype);

      Fit elements[] to the corresponding types of the struct's fields.


      Loc loc

      location to use for error messages

      Scope* sc


      Expressions* elements

      explicit arguments used to construct object

      Type stype

      the constructed object type.

      Return Value

      false if any errors occur, otherwise true and elements[] are rewritten for the output.

    • Declaration

      final bool isPOD();

      Determine if struct is POD (Plain Old Data).


      POD is defined as:

      1. not nested
      2. no postblits, destructors, or assignment operators
      3. no ref fields or fields that are themselves non-POD
      The idea being these are compatible with C structs.

      Return Value

      true if struct is POD

  • Declaration

    class UnionDeclaration: dmd.dstruct.StructDeclaration;

    Unions are a variation on structs.