#ifndef DYNAMIC_ARRAY_IMPL_H__ #define DYNAMIC_ARRAY_IMPL_H__ #include "Common.h" namespace Arrays { template struct DynamicArrayImpl { DynamicArrayImpl(const size_type size) : size_(size), content_(0), arr_(size==0 ? 0 : new T[size]) {} ~DynamicArrayImpl() { delete[] arr_; } void swap(DynamicArrayImpl& other) throw() // this function cannot throw an exception { std::swap(size_, other.size_); std::swap(content_, other.content_); std::swap(arr_, other.arr_); } void fill_from(const DynamicArrayImpl& other) { content_ = 0; while (content_ < other.content_ && content_ < size_) { arr_[content_] = other.arr_[content_]; ++content_; } } size_type size_; size_type content_; T* arr_; private: // Do not allow copies DynamicArrayImpl(const DynamicArrayImpl& other); DynamicArrayImpl& operator=(const DynamicArrayImpl& other); }; } #endif