make sure destruct doesnt call any virtual functions

[SVN r31167]
This commit is contained in:
Robert Ramey
2005-10-02 05:59:38 +00:00
parent 903da1f79a
commit ca999aaa88
2 changed files with 28 additions and 10 deletions

View File

@@ -38,18 +38,31 @@ class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info :
private:
virtual bool
less_than(const extended_type_info &rhs) const = 0;
int type_info_key_cmp(const extended_type_info & rhs) const;
// used to uniquely identify the type of class derived from this one
// so that different derivations of this class can be simultaneously
// included in implementation of sets and maps.
const char * type_info_key;
int type_info_key_cmp(const extended_type_info & rhs) const;
const char * m_type_info_key;
// flag to indicate wheter its been registered by type;
bool m_self_registered;
// flag to indicate wheter its been registered by type;
bool m_key_registered;
// flag indicating that no virtual function should be called here
// this is necessary since it seems that at least one compiler (borland
// and one version of gcc call less_than above when erasing even
// when given an iterator argument.
bool m_is_destructing;
protected:
const char * key;
extended_type_info(const char * type_info_key_);
const char * m_key;
extended_type_info(const char * type_info_key);
~extended_type_info();
public:
void self_register();
void key_register(const char *key);
bool is_destructing() const {
return m_is_destructing;
}
bool operator<(const extended_type_info &rhs) const;
bool operator==(const extended_type_info &rhs) const {
return this == & rhs;
@@ -58,7 +71,7 @@ public:
return this != & rhs;
}
const char * get_key() const {
return key;
return m_key;
}
static const extended_type_info * find(const char *key);
static const extended_type_info * find(const extended_type_info * t);

View File

@@ -42,9 +42,9 @@ namespace detail {
class BOOST_SERIALIZATION_DECL(BOOST_PP_EMPTY()) extended_type_info_no_rtti_0 :
public extended_type_info
{
protected:
virtual bool
less_than(const boost::serialization::extended_type_info &rhs) const ;
protected:
extended_type_info_no_rtti_0();
~extended_type_info_no_rtti_0();
public:
@@ -59,11 +59,11 @@ template<class T>
class extended_type_info_no_rtti_1 :
public extended_type_info_no_rtti_0
{
private:
// private constructor to inhibit any existence other than the
// static one
protected:
extended_type_info_no_rtti_1(){}
public:
// note borland complains at making this destructor protected
~extended_type_info_no_rtti_1(){};
static const boost::serialization::extended_type_info *
get_derived_extended_type_info(const T & t){
// find the type that corresponds to the most derived type.
@@ -93,7 +93,12 @@ public:
template<class T>
class extended_type_info_no_rtti :
public detail::extended_type_info_no_rtti_1<const T>
{};
{
// private constructor to inhibit any existence other than the
// static one
extended_type_info_no_rtti(){}
~extended_type_info_no_rtti(){};
};
} // namespace serialization
} // namespace boost