Summary: Add constructors for primitive types to make pointers
                    easier to use
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from Jonathan M Davis <> 2010-12-13 00:10:50 
PST ---
I'd like to be able to do something like this:

int* i = new int(7);

It would create a new pointer to int where the int that it points to has a
value of 7. But that code results in the compiler complaining that there is no
constructor for int, and as far as I can tell the only way to do it so the far
less elegant and definitely less compact:

int* i = new int;
*i = 7;

Ideally, you'd be able to use the first syntax for all primitive types. As it
is however, you can only use it for structs (and classes if you're using a
reference rather than a pointer). This seems unnecessarily limiting. In fact, I
thought that the first syntax _was_ legal, and it threw me off when it didn't
work (just goes to show how rarely I use pointers, I guess).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to