View source code
							
							
						
								Display the source code in std/experimental/checkedint.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Struct std.experimental.checkedint.ProperCompare
Hook that provides arithmetically correct comparisons for equality and ordering.
Comparing an object of type Checked!(X, ProperCompare) against another
integral (for equality or ordering) ensures that no surprising conversions from
signed to unsigned integral occur before the comparison. Using Checked!(X,
ProperCompare) on either side of a comparison for equality against a
floating-point number makes sure the integral can be properly converted to the
floating point type, thus making sure equality is transitive.
						
				struct ProperCompare
				;
						
					
				Methods
| Name | Description | 
|---|---|
| hookOpCmp | Hook for <,<=,>, and>=that ensures comparison against integral
    values has the behavior expected by the usual arithmetic rules. The built-in
    semantics yield surprising behavior when comparing signed values against
    unsigned values, for example0u < -1. The callhookOpCmp(x, y)returns-1if and only ifxis smaller thanyin abstract arithmetic
    sense. | 
| hookOpEquals | Hook for ==and!=that ensures comparison against integral values has
    the behavior expected by the usual arithmetic rules. The built-in semantics
    yield surprising behavior when comparing signed values against unsigned
    values for equality, for exampleuintor-1_294_967_296 ==
    3_000_000_000u. The callhookOpEquals(x, y)returnstrueif and only
    ifxandyrepresent the same arithmetic number. | 
Example
alias opEqualsProper = ProperCompareAuthors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.