mirror of
https://github.com/boostorg/move.git
synced 2025-07-30 12:27:14 +02:00
Fix potential self-move points
This commit is contained in:
@ -175,7 +175,8 @@ void swap_and_update_key
|
||||
{
|
||||
if(begin != with){
|
||||
::boost::adl_move_swap_ranges(begin, end, with);
|
||||
::boost::adl_move_swap(*key_next, *key_range2);
|
||||
if(key_next != key_range2) //Avoid potential self-swapping
|
||||
::boost::adl_move_swap(*key_next, *key_range2);
|
||||
if(key_next == key_mid){
|
||||
key_mid = key_range2;
|
||||
}
|
||||
@ -217,7 +218,8 @@ RandIt2 buffer_and_update_key
|
||||
while(begin != end) {
|
||||
op(three_way_t(), begin++, with++, buffer++);
|
||||
}
|
||||
::boost::adl_move_swap(*key_next, *key_range2);
|
||||
if (key_next != key_range2) //Avoid potential self-swapping
|
||||
::boost::adl_move_swap(*key_next, *key_range2);
|
||||
if (key_next == key_mid) {
|
||||
key_mid = key_range2;
|
||||
}
|
||||
|
@ -192,7 +192,8 @@ namespace pdqsort_detail {
|
||||
|
||||
// Put the pivot in the right place.
|
||||
Iter pivot_pos = first - 1;
|
||||
*begin = boost::move(*pivot_pos);
|
||||
if(begin != pivot_pos) //Avoid potential self-move
|
||||
*begin = boost::move(*pivot_pos);
|
||||
*pivot_pos = boost::move(pivot);
|
||||
|
||||
return pdqsort_detail::pair<Iter, bool>(pivot_pos, already_partitioned);
|
||||
|
Reference in New Issue
Block a user