~Array1D() { Alloc alloc; for (int i = 0; i < mSize; ++i) { alloc.destroy(&mData[i]); } alloc.deallocate(mData, mSize); }
inline void uninitialized_fill_n_with_alloc(ForwardIterator first, Diff n, const T& item, Alloc& alloc) { ForwardIterator next = first; BOOST_TRY { for (; n > 0; ++first, --n) alloc.construct(first, item); } BOOST_CATCH(...) { for (; next != first; ++next) alloc.destroy(next); BOOST_RETHROW } BOOST_CATCH_END }
inline ForwardIterator uninitialized_copy_with_alloc(InputIterator first, InputIterator last, ForwardIterator dest, Alloc& alloc) { ForwardIterator next = dest; BOOST_TRY { for (; first != last; ++first, ++dest) alloc.construct(dest, *first); } BOOST_CATCH(...) { for (; next != dest; ++next) alloc.destroy(next); BOOST_RETHROW } BOOST_CATCH_END return dest; }
void allocator_traits<Alloc>::destroy(Alloc& a, T* p) { a.destroy(p); //TODO: It may not be implemented }