From 94ca0327eff258a4c51070070476769a92551733 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 20 Mar 2022 11:39:00 +0100 Subject: [PATCH] Adds copy and assignment operators for Dictionary --- src/Collections/Dictionary.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Collections/Dictionary.hpp b/src/Collections/Dictionary.hpp index 77aaec8..d5af343 100644 --- a/src/Collections/Dictionary.hpp +++ b/src/Collections/Dictionary.hpp @@ -26,6 +26,16 @@ namespace ArbUt { /// @brief Initialises a dictionary from an initializer_list. Dictionary(const std::initializer_list>& l) : _map(new std::unordered_map(l)) {} + /// @brief Copy operator + Dictionary(const Dictionary& other) noexcept : _map(other._map) {} + /// @brief Assignment operator + Dictionary& operator=(const Dictionary& other) noexcept { + if (this == &other || _map == other._map) { + return *this; + } + _map = other._map; + return *this; + } /// @brief Removes all items from the dictionary. inline void Clear() noexcept { _map->clear(); }