memcpy, memset, memcmp and friends in the D Runtime

monarch_dodra monarchdodra at gmail.com
Thu Apr 10 05:28:01 PDT 2014


On Thursday, 10 April 2014 at 12:22:37 UTC, Daniel Murphy wrote:
> "Dmitry Olshansky"  wrote in message 
> news:li5lfd$203s$1 at digitalmars.com...
>
>> Pros:
>> 
>> 1. No extra scuffolding for CTFE.
>> 2. Type-safe
>> 3. Optional (non-release, etc.) bounds-checking.
>> 4. Less error prone interface, e.g. memset is a known source 
>> of bugs in C, even for tried and true code bases.
>> 5. More flexible, see e.g. memchr as an example.
>> 
>> Cons:
>> A set of primitives to learn.
>
> I don't know why you'd ever use memcpy/memset when you have:
>
> arr[] = 0;
> foreach(ref v; arr)
>    v = 0;
> etc

Because those are assignments.


More information about the Digitalmars-d mailing list