How it works...

Currently, our custom container is capable of being constructed, added to, iterated over, and erased. The container does not, however, support the ability to directly access the container or support simple operations, such as a std::move() or comparison. To address these issues, let's start by adding the operator=() overloads that are missing:

    constexpr container &operator=(const container &other)    {        m_v = other.m_v;        return *this;    }    constexpr container &operator=(container &&other) noexcept    {        m_v = std::move(other.m_v);        return *this;    }    

The first operator=() overload provides support for a copy assignment, while the second overload provides support for a move assignment. Since we only have a single private member variable ...

Get Advanced C++ Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.