[Issue 5347] New: Add constructors for primitive types to make pointers easier to use
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 13 00:12:36 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5347
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
AssignedTo: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 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: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list