$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (abrahams_at_[hidden])
Date: 2000-08-26 19:06:16
Hi boost!
I am writing some classes which I plan to allocate out of a special memory
pool, but never destroy (mostly for speed). I am just going to release the
memory pool to clean up. Naturally, these objects must have trivial
destructors. What's the problem? Well, I want to use some boost classes as
bases and sub-objects of my classes. For example:
typedef unsigned long PrimaryCost;
typedef float StructureCost;
struct Cost
: boost::equality_comparable<
boost::less_than_comparable<Cost> >
{
Cost() : primary(), structure() {}
PrimaryCost primary;
StructureCost structure;
bool operator<(const Cost& rhs) const
{ return primary < rhs.primary || primary == rhs.primary &&
structure < rhs.structure; }
bool operator==(const Cost& rhs) const
{ return primary == rhs.primary && structure == rhs.structure; }
};
Unless I know that equality_comparable and less_than_comparable have trivial
destructors, I can't use them as shown above. I suggest that we begin to pay
attention to this little detail, and when trivial ctors or dtors are present
in a class, we mention it in our documentation pages.
I imagine there must be other similar properties we're ignoring. I wonder
whether one can technically count on std::pair having a trivial dtor?
Thoughts?
Dave