std.algorithm.copy could be better optimized
TommiT
tommitissari at hotmail.com
Mon Jun 17 10:36:21 PDT 2013
std.algorithm.copy adheres to the specification of the C++
standard library function std::copy. That specification states
that the source and target ranges may not overlap. Yet, all the
major C++ standard libraries (libc++, libstdc++, Dinkum C++
Library) implement std::copy so that it becomes a memmove if the
source and target element types are the same and the element type
is std::is_trivially_copy_assignable. Thus, the current C++
specification seems to be too strict.
The current std.algorithm.copy implementation doesn't get
optimized into a memmove when it would be safe to do so. It
really should, because it's the fastest way to get the job done,
and it allows the ranges to overlap. Also, the documentation
should be changed to notify of this relaxation.
There's some benchmarks of memmove vs other methods:
http://nadeausoftware.com/articles/2012/05/c_c_tip_how_copy_memory_quickly
More information about the Digitalmars-d
mailing list