github.com/wfusion/gofusion@v1.1.14/common/constraint/basic.go (about)

     1  package constraint
     2  
     3  // Signed is a constraint that permits any signed integer type.
     4  // If future releases of Go add new predeclared signed integer types,
     5  // this constraint will be modified to include them.
     6  type Signed interface {
     7  	~int | ~int8 | ~int16 | ~int32 | ~int64
     8  }
     9  type Signedp interface {
    10  	~*int | ~*int8 | ~*int16 | ~*int32 | ~*int64
    11  }
    12  
    13  // Unsigned is a constraint that permits any unsigned integer type.
    14  // If future releases of Go add new predeclared unsigned integer types,
    15  // this constraint will be modified to include them.
    16  type Unsigned interface {
    17  	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
    18  }
    19  type Unsignedp interface {
    20  	~*uint | ~*uint8 | ~*uint16 | ~*uint32 | ~*uint64 | ~*uintptr
    21  }
    22  
    23  // Integer is a constraint that permits any integer type.
    24  // If future releases of Go add new predeclared integer types,
    25  // this constraint will be modified to include them.
    26  type Integer interface {
    27  	Signed | Unsigned
    28  }
    29  type Integerp interface {
    30  	Signedp | Unsignedp
    31  }
    32  
    33  // Float is a constraint that permits any floating-point type.
    34  // If future releases of Go add new predeclared floating-point types,
    35  // this constraint will be modified to include them.
    36  type Float interface {
    37  	~float32 | ~float64
    38  }
    39  type Floatp interface {
    40  	~*float32 | ~*float64
    41  }
    42  
    43  // Complex is a constraint that permits any complex numeric type.
    44  // If future releases of Go add new predeclared complex numeric types,
    45  // this constraint will be modified to include them.
    46  type Complex interface {
    47  	~complex64 | ~complex128
    48  }
    49  type Complexp interface {
    50  	~*complex64 | ~*complex128
    51  }
    52  
    53  // Sortable is a constraint that permits any ordered type: any type
    54  // that supports the operators < <= >= >.
    55  // If future releases of Go add new ordered types,
    56  // this constraint will be modified to include them.
    57  type Sortable interface {
    58  	Integer | Float | ~string
    59  }
    60  type Sortablep interface {
    61  	Integerp | Floatp | ~*string
    62  }