Bug 9637 – std.typecons.nullable and nullableRef functions

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-02T13:37:47Z
Last change time
2024-12-01T16:16:48Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#9959 →

Comments

Comment #0 by bearophile_hugs — 2013-03-02T13:37:47Z
Spinoff of Issue 9265 I suggest to add to std.typecons two small functions that help the creation of a Nullable and NullableRef: import std.typecons; void main() { int x; auto n1 = Nullable!int(x); auto n2 = NullableRef!int(&x); auto n3 = nullable(x); // missing auto n4 = nullableRef(&x); // missing } This gets handy when the type of the item is complex: auto n = nullable(data); Instead of: auto n = Nullable!(immutable int[4])(data); - - - - - - - - - - - - Note: maybe it's possible to support Nullable(T, T nullValue) like this: auto n5 = nullable!(int.max)(x); But maybe for simplicity it's better to not support this.
Comment #1 by robert.schadek — 2024-12-01T16:16:48Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9959 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB