D
Dennis Jones
Hi all,
1) Let's say you have two char []'s of the same size. How would you write a
no-fail swap method for them? For example:
class Test
{
char s[10];
void swap( Test &rhs )
{
// is it possible to swap the data member 's' with the no-fail
guarantee?
}
};
2) If the data member is a pointer (char *), is std::swap sufficient (even
if the other pointer was allocated with a different size)? For example:
class Test
{
char *s; // assume this is allocated to some size
void swap( Test &rhs )
{
std::swap( s, rhs.s ); // is this okay?
}
};
Thanks,
- Dennis
1) Let's say you have two char []'s of the same size. How would you write a
no-fail swap method for them? For example:
class Test
{
char s[10];
void swap( Test &rhs )
{
// is it possible to swap the data member 's' with the no-fail
guarantee?
}
};
2) If the data member is a pointer (char *), is std::swap sufficient (even
if the other pointer was allocated with a different size)? For example:
class Test
{
char *s; // assume this is allocated to some size
void swap( Test &rhs )
{
std::swap( s, rhs.s ); // is this okay?
}
};
Thanks,
- Dennis