Bug 1855 – .dup property for value types

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-02-20T09:34:00Z
Last change time
2016-10-14T00:55:22Z
Assigned to
nobody
Creator
aarti

Comments

Comment #0 by aarti — 2008-02-20T09:34:26Z
There should be .dup property also for all built-in value types (char, int etc.) It will allow greater consistency in generic programming. Currently changing type from e.g. string to char you have to change also implementation of duplicating method: struct StringDescription { public: string delimiter = "MYDELIM"; //char delimiter = '"'; dup() has error typeof(*this) dup() { typeof(*this) result; result.delimiter = delimiter.dup; return result; } } It shouldn't be very difficult to implement this enhancement as .dup for values can be simply ignored.
Comment #1 by andrei — 2016-10-14T00:55:22Z
A simple "static if" takes care of this.