简体   繁体   中英

what is the different between memmove and c++11 std::move?

What is the different between memmove and c++11 std::move ? Can I use std::move on overlapped memory location? And which method has the higher speed performance?

A few ways:

  1. std::move invokes assignment operators, while memmove does not. As such, memmove is not appropriate for non-POD types.
  2. std::move will work on any C++ container type, while memmove will only work on those which store elements linearly in contiguous memory locations (such as with arrays and std::vector).
  3. std::move is not appropriate for a destination range which overlaps the source range on the left (use move_backwards for that), while memmove is appropriate for all overlapping ranges.

In situations where you're copying POD types to a right-overlapping range, it is likely that memmove and std::move will have similar performance. In all other situations, only one of the two is appropriate, so you can't really compare performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM