/* * Container.h Step 4, Inserting and removing elements. */ #ifndef CONTAINER_H #define CONTAINER_H #include template class Container { public: using size_type = std::size_t; Container() noexcept = default; explicit Container(const size_type n); Container(const Container&); Container(Container&&) noexcept; ~Container(); Container& operator=(const Container&) &; Container& operator=(Container&&) & noexcept; size_type size() const noexcept; size_type max_size() const noexcept; size_type capacity() const noexcept; bool empty() const noexcept; void clear() noexcept; void push_back(const T&); // added T& back(); // added const T& back() const; // added void pop_back() noexcept; // added void swap(Container&) noexcept; private: T* start_{ nullptr }; T* finish_{ nullptr }; T* end_of_storage_{ nullptr }; size_type compute_capacity_() const; // added T* allocate_(size_type); void deallocate_(T*); T* allocate_and_copy_(const Container&); void resize_(const T&); // added }; template void swap(Container&, Container&) noexcept; #include "Container.tcc" #endif