|
Boost : |
From: Ivan J. Johnson (ivan66_at_[hidden])
Date: 1999-11-21 15:41:40
Your specialization for swap (shown below) should probably be inline.
// std::swap for empty_member
namespace std {
template <typename Base, typename Member>
void swap(empty_member<Base, Member> & a,
empty_member<Base, Member> & b)
{
// swap base classes in-place: for empty base classes, this will
optimize
// away to nothing
std::swap((Base &) a, (Base &) b);
// swap member objects in-place
std::swap(a.m, b.m);
}
} // namespace std
Also, as Darin pointed out, it might be better to avoid the C-style
cast. Rather than using static_cast, I think you could write
std::swap<Base>(a, b);
which is effectively an implicit_cast.
--Ivan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk