[phobos] swap()

David Simcha dsimcha at gmail.com
Thu Sep 2 20:58:08 PDT 2010


  A few questions about std.algorithm.swap() that came up when I was 
reading the code to fix Bug 4789:

1.  Do we really need to use memcpy() for structs w/o a postblit?  I 
can't see any advantages and it seems like it might be less efficient, 
since for a struct without a postblit just using plain old assignment 
should be about as efficient as it gets.

2.  memcpy() isn't guaranteed to work for overlapping memory blocks.  
Shouldn't there be a check in to make sure a and b don't have the same 
address?


More information about the phobos mailing list