Behavior of F# “unmanaged” type constraint

后端 未结 3 538
猫巷女王i
猫巷女王i 2021-01-01 13:58

F# supports a type constraint for \"unmanaged\". This is not the same as a value type constraint like \"struct\" constraints. MSDN notes that the behavior of the unmanaged

3条回答
  •  遥遥无期
    2021-01-01 14:54

    The CorGenericParamAttr Enumeration in CorHdr.h lists all possible constraint flags at CIL level, so an unmanaged constraint is purely enforced by the F# compiler.

    typedef enum CorGenericParamAttr {
        gpVarianceMask                     =   0x0003,
        gpNonVariant                       =   0x0000, 
        gpCovariant                        =   0x0001,
        gpContravariant                    =   0x0002,
    
        gpSpecialConstraintMask            =   0x001C,
        gpNoSpecialConstraint              =   0x0000,
        gpReferenceTypeConstraint          =   0x0004, 
        gpNotNullableValueTypeConstraint   =   0x0008,
        gpDefaultConstructorConstraint     =   0x0010
    } CorGenericParamAttr;
    

提交回复
热议问题