|
Boost : |
Subject: Re: [boost] [type_traits] optimized std::copy example wrong?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-04-24 12:29:30
AMDG
strasser_at_[hidden] wrote:
> Zitat von Thorsten Ottosen <nesotto_at_[hidden]>:
>
>> Hi John & co,
>>
>> IIRC, std::copy() cannot use memcpy(), since the memory is allowed to
>> overlap. Therefore it can only use memmove().
>
> std::copy() doesn't allow overlapping ranges. -> std::copy_backward()
Both copy and copy_backwards allow some overlapping ranges.
int array[10] = {};
std::copy(&array[0], &array[7], &array[1]); // illegal
std::copy(&array[1], &array[8], &array[0]); // okay
std::copy_backwards(&array[0], &array[7], &array[8]); // okay
std::copy_backwards(&array[1], &array[8], &array[7]); // illegal
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk