move m_initialized = false ; to destroy()

[SVN r77153]
This commit is contained in:
Christopher Hite
2012-03-02 16:38:58 +00:00
parent 776ed89fb3
commit cb9e852350

View File

@ -435,8 +435,10 @@ class optional_base : public optional_tag
void destroy() void destroy()
{ {
if ( m_initialized ) if ( m_initialized ){
destroy_impl(is_reference_predicate()) ; destroy_impl(is_reference_predicate()) ;
m_initialized = false ;
}
} }
unspecified_bool_type safe_bool() const { return m_initialized ? &this_type::is_initialized : 0 ; } unspecified_bool_type safe_bool() const { return m_initialized ? &this_type::is_initialized : 0 ; }
@ -474,12 +476,12 @@ class optional_base : public optional_tag
reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; } reference_type dereference( internal_type* p, is_reference_tag ) { return p->get() ; }
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581)) #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x581))
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; m_initialized = false ; } void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->internal_type::~internal_type() ; }
#else #else
void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ; m_initialized = false ; } void destroy_impl ( is_not_reference_tag ) { get_ptr_impl()->T::~T() ; }
#endif #endif
void destroy_impl ( is_reference_tag ) { m_initialized = false ; } void destroy_impl ( is_reference_tag ) { }
// If T is of reference type, trying to get a pointer to the held value must result in a compile-time error. // If T is of reference type, trying to get a pointer to the held value must result in a compile-time error.
// Decent compilers should disallow conversions from reference_content<T>* to T*, but just in case, // Decent compilers should disallow conversions from reference_content<T>* to T*, but just in case,