View source code
Display the source code in std/typecons.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aGitHub 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 usinglocal clone.
Function std.typecons.Nullable.opCmp
Compares two Nullable values.
int opCmp(This, Rhs)(
auto ref Rhs rhs
)
if (is(Rhs == Nullable!U, U) && is(typeof(this .get < rhs .get)));
- If one is null and the other is not, the null one is considered smaller. - If both are null, they are equal. - If both are non-null, compares the payloads.
Returns
Negative if this < rhs, zero if equal, positive if this > rhs.
Example
Basic Nullable comparison test
Nullable!int a = 5;
Nullable!int b = 0;
assert(a > b);
assert(b < a);
Nullable!int c;
assert(c < a);
assert(c < b);
Authors
Andrei Alexandrescu, Bartosz Milewski, Don Clugston, Shin Fujishiro, Kenji Hara
License
Copyright © 1999-2026 by the D Language Foundation | Page generated by ddox.