copying memory in phobos

Mike none at none.com
Tue Apr 8 02:43:02 PDT 2014


I ran accross the following code in phobos std.array:

void trustedMemcopy(T[] dest, T[] src) @trusted
{
     assert(src.length == dest.length);
     if (!__ctfe)
         memcpy(dest.ptr, src.ptr, src.length * T.sizeof);
     else
     {
         dest[] = src[];
     }
}

Why two different implementations for copying memory (i.e. memcpy 
vs. dest[] = src[])? Why not use dest[] = src[] exclusively.

Thanks for the help,
Mike


More information about the Digitalmars-d-learn mailing list