www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14477] New: Nullable does not work with structs with default


          Issue ID: 14477
           Summary: Nullable does not work with structs with default
                    constructor disabled
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: justin economicmodeling.com

The following simple code does not compile:
import std.typecons;
struct Foo
    int x;
     disable this();
    this(int value) { x=value; }

void main()
    Nullable!Foo foo;
test.d(14): Error: variable test.main.foo default construction is disabled for
type Nullable!(Foo)

Of course, one of the major use-cases for Nullable is to provide a way to
default-initialize such a struct to a "null" state.

Apr 21 2015