6. }
private:
Node* m_nodePtr{nullptr};
friend class List;
};
// transfers [first, last) to before pos and sets all links
static void
transfer (const_iterator pos, const_iterator first, const_iterator last)
{
if (first == last)
{
return;
}
first.m_nodePtr->prev->next = last.m_nodePtr->next;
last.m_nodePtr->next->prev = first.m_nodePtr->prev;
pos.m_nodePtr->hook(first.m_nodePtr, last.m_nodePtr);
}
public:
// default constructor
List ()
/* remember to include the member initializer list */
{
// TODO
// make m_header a circular node
}
// size-value constructor
explicit List (size_type count, T const& value) : List ()
{
// TODO
}
explicit List (size_type count) : List ()
{
while (count--)
{
emplace_back ();
}
}
// range constructor
template<typename InputIt, Requires (concepts::ForwardIterator, InputIt)>
List (InputIt first, InputIt last) : List ()
{
// TODO
7. }
// copy constructor
List (List const& other) : List (other.begin (), other.end ())
{
}
// move constructor
List (List&& other)
: m_header (std::exchange (other.m_header, Node ()))
, m_size (std::exchange (other.m_size, 0))
{
}
// intializer_list constructor
List (std::initializer_list<T> init) : List (init.begin (), init.end ())
{
}
// destructor
~List ()
{
// TODO
// Remember to delete all allocated nodes!
}
// copy assignment
List&
operator= (List const& other)
{
// TODO
// Remember to check for self-assignment
// Hint: look at versions of assign() below...
}
// move assignment
List&
operator= (List&& other) noexcept
{
if (&other != this)
{
clear ();
m_header.next = std::exchange (other.m_header.next, &(other.m_header));
m_header.prev = std::exchange (other.m_header.prev, &(other.m_header));
m_size = std::exchange (other.m_size, 0);
}
return *this;
8. }
// initializer_list assignment
List&
operator= (std::initializer_list<T> ilist)
{
assign (ilist);
return *this;
}
void
assign (size_type count, T const& value)
{
List l (count, value);
swap (l);
}
template<typename InputIt, Requires (concepts::ForwardIterator, InputIt)>
void
assign (InputIt first, InputIt last)
{
List l (first, last);
swap (l);
}
void
assign (std::initializer_list<T> ilist)
{
// TODO
}
...
private:
Node m_header;
size_type m_size;
};
...
Please complete the implementation marked TODO for the above member functions.