[Issue 12512] Feature request: cdup

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 13 04:47:43 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12512

Nick Treleaven <ntrel-public at yahoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ntrel-public at yahoo.co.uk

--- Comment #4 from Nick Treleaven <ntrel-public at yahoo.co.uk> ---
(In reply to monarchdodra from comment #3)
> Just to be clear, my need is:
> Given a type T (which may be qualified), I need a function that can do this:
> 
> //----
> T[] output = intput.someDup();
> //----

You can just use dup:

    int[] ma = [1, 2, 3];
    immutable(int)[] ia = ma.dup;

I think current dmd can do this because it knows ma.dup is unique, so it can
safely convert to immutable.

--


More information about the Digitalmars-d-bugs mailing list