|
Boost : |
From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2003-08-26 04:13:55
"Edward Diener" <eddielee_at_[hidden]> wrote in message
news:biedm2$dt8$1_at_sea.gmane.org...
> Extremely dangerous and error prone. I can't even imagine a non-POD type
> where flagging it for memcpy_copyable and memcpy_moveable can be right.
Can
> you give an example ?
>
It is error prone but many other constructs are too.
Example of moveable object:
struct string_buffer {
unsigned size;
char* data; // allocated buffer
};
The user could then write:
template<> memcpy_moveable<string_buffer> {
static bool moveable = true; // or defining some type or so
}
and container can detect moveability and use memcpy(). If type is not
flagged, memcpy() won't be used.
Usually strings, smart pointers, vectors, pimpls are memcpy moveable. Pimpl
with back pointer isn't.
(The memcpy_copyable<> is probably not that good idea and not much useful.)
/Pavel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk