Skip to Content
Advanced C++ Programming Cookbook
book

Advanced C++ Programming Cookbook

by Dr. Rian Quinn
January 2020
Intermediate to advanced
454 pages
11h 25m
English
Packt Publishing
Content preview from Advanced C++ Programming Cookbook

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern C++ Programming Cookbook

Modern C++ Programming Cookbook

Marius Bancila

Publisher Resources

ISBN: 9781838559915Supplemental Content