On Sep 12, 2013, at 6:23 PM, Howard Hinnant <[email protected]> wrote:

> Need to decrement __data prior to the destruction instead of after:
> 
> template <class _Tp>
> inline _LIBCPP_INLINE_VISIBILITY
> dynarray<_Tp>::~dynarray()
> { 
>    value_type *__data = data () + __size_;
>    for ( size_t i = 0; i < __size_; ++i )
>    {
>        --__data;
>        __data->value_type::~value_type();
>    }
>    __deallocate ( __base_ );
> }

Yesterday, I changed this to:

+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY
+dynarray<_Tp>::~dynarray()
+{ 
+    value_type *__data = data () + __size_;
+    for ( size_t i = 0; i < __size_; ++i )
+        (--__data)->value_type::~value_type();
+    __deallocate ( __base_ );
+}


Richard wrote:
> Hmm, what should size() return if it's called during the destruction of the 
> dynarray?

Once we've entered the destructor, the object has ceased to be. It is an 
ex-object.

> During construction, it returns the number of fully-constructed elements. 
> Maybe we should do the same here:

That's done because it makes the cleanup easier, rather than worrying about 
people calling methods on the object during the constructor.

-- Marshall

Marshall Clow     Idio Software   <mailto:[email protected]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly 
moderated down to (-1, Flamebait).
        -- Yu Suzuki


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to