Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-09 15:00:35


--- Brian McNamara <lorgon_at_[hidden]> wrote:
> On Wed, Oct 08, 2003 at 08:48:28PM -0700, E. Gladyshev wrote:
> > Here is how I would do it.
> ...
> > //doesn't throw
> > void variant_copy( char* dst, char* src, size_t size ) {
> > for( size_t i = 0; i < size; ++i, ++dst, ++src ) {
> > *dst = *src;
> > }
> > }
> ...
> > //save the current data
> > variant_copy( b1, data_, size );
> ...
> > //copy the new object to another storage
> > variant_copy( b2, data_, size );
> > //copy the original object back for destruction
> > variant_copy( data_, b1, size );
> > static_cast<T*>((void*)data_)->~T();
> > //put the new object back in place
> > variant_copy( data_, b2, size );
>
> This is clever. Is it legal? I know it's legal for POD types. I can't
> find text in the standard which makes it legal for non-POD types. But
> at the same time, offhand I can't imagine an implementation where it
> wouldn't work.

Brian, where in my code do you see non-POD copying?
All it does, it copies one char[] to another char[]
(both are POD types).
The char arrays where allocated as char arrays
originally, there is not any casting going on.
What are you concerns exactly?

Eugene

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk