diff --git a/include/const_list.h b/include/const_list.h index 1306694..0417f28 100644 --- a/include/const_list.h +++ b/include/const_list.h @@ -13,10 +13,11 @@ namespace cc { + template class const_list_node; template - requires std::derived_from + requires std::derived_from> class _const_list_iterator_base { protected: N *_curr; @@ -68,32 +69,28 @@ namespace cc { constexpr _const_const_list_iterator operator--(int) & noexcept override { auto tmp = *this; _Base::_curr == _Base::_curr->_prev; return tmp; } }; - template - requires std::derived_from + template + requires std::derived_from> class const_list { public: - using value_type = N; + using value_type = node; using size_type = std::size_t; using difference_type = std::ptrdiff_t; using reference = value_type&; using const_reference = const value_type&; using pointer = value_type *; using const_pointer = const value_type *; - using iterator = _const_list_iterator; - using const_iterator = _const_const_list_iterator; + using iterator = _const_list_iterator; + using const_iterator = _const_const_list_iterator; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - private: - const_list_node *_start; - const_list_node *_end; - std::size_t _size; - CompileOptional> _alloc; - - using alloc_defined = decltype(_alloc)::defined; + node *_start = nullptr; + node *_end = nullptr; + std::size_t _size = 0; public: @@ -110,7 +107,7 @@ namespace cc { constexpr const_list& operator=(const const_list& other); constexpr const_list& operator=(const_list&& other); - constexpr const_list& operator=(std::initializer_list init); + constexpr const_list& operator=(std::initializer_list init); constexpr void assign(size_type count, const value_type& value) noexcept; template @@ -208,10 +205,15 @@ namespace cc { }; + template class const_list_node { + static_assert(std::is_base_of_v, D>); private: - const_list_node *_prev; - const_list_node *_next; + const_list_node *_prev = nullptr; + const_list_node *_next = nullptr; + const_list *_owner = nullptr; + + virtual ~const_list_node(); friend class const_list; friend class _const_list_iterator_base; @@ -221,390 +223,44 @@ namespace cc { template const_list(InputIt, InputIt) -> const_list::value_type>; - template - constexpr bool operator==(const const_list& lhs, - const const_list& rhs) + template + constexpr bool operator==(const const_list& lhs, + const const_list& rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } - template - constexpr auto operator<=>(const const_list& lhs, - const const_list& rhs) + template + constexpr auto operator<=>(const const_list& lhs, + const const_list& rhs) { return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } - template - constexpr void swap(const const_list& lhs, - const const_list& rhs) + template + constexpr void swap(const const_list& lhs, + const const_list& rhs) { lhs.swap(rhs); } - template - constexpr const_list::size_type erase(const_list& c, const N& value) + template + constexpr const_list::size_type erase(const_list& c, const N& value) { c.remove(value); } - template - constexpr const_list::size_type erase(const_list& c, Pred pred) + template + constexpr const_list::size_type erase(const_list& c, Pred pred) { c.remove_if(pred); } - template - requires std::derived_fromconstexpr - const_list::const_list(const_list::size_type count) noexcept - { - } - - template - requires std::derived_fromconstexpr - const_list::const_list(const_list::size_type count, const value_type &value) noexcept - { - - } - - template - requires std::derived_from - template - constexpr const_list::const_list(InputIt first, InputIt last) - { - - } - - template - requires std::derived_fromconstexpr - const_list::const_list(const const_list &other) noexcept - { - - } - - template - requires std::derived_fromconstexpr - const_list::const_list(const_list &&other) noexcept - { - - } - - template - requires std::derived_fromconstexpr - const_list::const_list(std::initializer_list init) noexcept - { - - } - - template - requires std::derived_fromconstexpr const_list::~const_list() - { - - } - - template - requires std::derived_fromconstexpr const_list & - const_list::operator=(const const_list &other) - { - return <#initializer#>; - } - - template - requires std::derived_fromconstexpr const_list & - const_list::operator=(const_list &&other) - { - return <#initializer#>; - } - - template - requires std::derived_fromconstexpr const_list & - const_list::operator=(std::initializer_list init) - { - return <#initializer#>; - } - - template - requires std::derived_fromconstexpr void - const_list::assign(const_list::size_type count, const value_type &value) noexcept - { - - } - - template - requires std::derived_from - template - constexpr void const_list::assign(InputIt first, InputIt last) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::assign(std::initializer_list values) - { - - } - - template - requires std::derived_fromvoid const_list::clear() noexcept - { - - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::insert(const_list::const_iterator pos, const value_type &value) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::insert(const_list::const_iterator pos, value_type &&value) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::insert(const_list::const_iterator pos, const_list::size_type count, const value_type &value) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_from - template - constexpr const_list::iterator - const_list::insert(const_list::const_iterator pos, InputIt first, InputIt last) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::insert(const_list::const_iterator pos, std::initializer_list values) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_from - template - constexpr const_list::iterator const_list::emplace(const_list::const_iterator pos, Args &&... args) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::erase(const_list::const_iterator pos) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr const_list::iterator - const_list::erase(const_list::const_iterator first, const_list::const_iterator last) - { - return cc::const_list::iterator(); - } - - template - requires std::derived_fromconstexpr void - const_list::push_back(const value_type &value) - { - - } - - template - requires std::derived_fromconstexpr void const_list::push_back(value_type &&value) - { - - } - - template - requires std::derived_from - template - constexpr reference const_list::emplace_back(Args &&... args) - { - return <#initializer#>; - } - - template - requires std::derived_fromconstexpr void const_list::pop_back() - { - - } - - template - requires std::derived_fromconstexpr void - const_list::push_front(const value_type &value) - { - - } - - template - requires std::derived_fromconstexpr void const_list::push_front(value_type &&value) - { - - } - - template - requires std::derived_from - template - constexpr reference const_list::emplace_front(Args &&... args) - { - return <#initializer#>; - } - - template - requires std::derived_fromconstexpr void const_list::pop_front() - { - - } - - template - requires std::derived_fromconstexpr void - const_list::resize(const_list::size_type count) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::resize(const_list::size_type count, const value_type &value) - { - - } - - template - requires std::derived_fromconstexpr void const_list::swap(const_list &other) noexcept - { - - } - - template - requires std::derived_fromconstexpr void const_list::merge(const_list &other) - { - - } - - template - requires std::derived_fromconstexpr void const_list::merge(const_list &&other) - { - - } - - template - requires std::derived_from - template - constexpr void const_list::merge(const_list &other, Compare comp) - { - - } - - template - requires std::derived_from - template - constexpr void const_list::merge(const_list &&other, Compare comp) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &other) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &&other) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &other, const_list::const_iterator it) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &&other, const_list::const_iterator it) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &other, const_list::const_iterator first, - const_list::const_iterator last) - { - - } - - template - requires std::derived_fromconstexpr void - const_list::splice(const_list::const_iterator pos, const_list &&other, const_list::const_iterator first, - const_list::const_iterator last) - { - - } - - template - requires std::derived_fromconstexpr const_list::size_type - const_list::remove(const value_type &value) - { - return 0; - } - - template - requires std::derived_from - template - const_list::size_type const_list::remove_if(UnaryPredicate p) - { - return 0; - } - - template - requires std::derived_fromvoid const_list::reverse() noexcept - { - - } - - template - requires std::derived_fromconst_list::size_type const_list::unique() - { - return 0; - } - - template - requires std::derived_from - template - constexpr const_list::size_type const_list::unique(BinaryPredicate p) - { - return 0; - } - - template - requires std::derived_fromconstexpr void const_list::sort() - { - - } - - template - requires std::derived_from - template - void const_list::sort(Compare comp) - { - - } + template + const_list_node::~const_list_node() { + _owner->remove(*this); + } } // cc